博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 5597 GTW likes function 打表
阅读量:5147 次
发布时间:2019-06-13

本文共 1424 字,大约阅读时间需要 4 分钟。

GTW likes function

题目连接:

Description

Now you are given two definitions as follows.

f(x)=∑xk=0(−1)k22x−2kCk2x−k+1,f0(x)=f(x),fn(x)=f(fn−1(x))(n≥1)

Note that φ(n) means Euler’s totient function.(φ(n)is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to n.)

For each test case, GTW has two positive integers — n and x, and he wants to know the value of the function φ(fn(x)).

Input

There is more than one case in the input file. The number of test cases is no more than 100. Process to the end of the file.

Each line of the input file indicates a test case, containing two integers, n and x, whose meanings are given above. (1≤n,x≤1012)

Output

In each line of the output file, there should be exactly one number, indicating the value of the function φ(fn(x)) of the test case respectively.

Sample Input

1 1

2 1

3 2

Sample Output

2

2

2

Hint

题意

651210-20151212224122231-675940764.png

题解:

一切反动派都是纸老虎

打表之后很容易发现,f(x) = x+1

于是这道题就很蠢了,直接输出phi(n+x+1)就好了

代码

#include
#include
using namespace std;long long phi(long long n){ long long tmp=n; for(long long i=2;i*i<=n;i++) if(n%i==0) { tmp/=i;tmp*=i-1; while(n%i==0)n/=i; } if(n!=1)tmp/=n,tmp*=n-1; return tmp;}int main(){ long long n,x; while(scanf("%I64d%I64d",&n,&x)!=EOF) printf("%I64d\n",phi(x+n+1)); return 0;}

转载于:https://www.cnblogs.com/qscqesze/p/5042003.html

你可能感兴趣的文章
windows pear 安装
查看>>
22Spring基于配置文件的方式配置AOP
查看>>
H5页面在微信端的分享
查看>>
python13 1.函数的嵌套定义 2.global、nonlocal关键字 3.闭包及闭包的运用场景 4.装饰器...
查看>>
例6-5
查看>>
eclipse变量名自动补全
查看>>
一个数据库操作类(包含弹出对话框函数,也可自定义弹出的脚本内容)
查看>>
HIVE文件
查看>>
转——调试寄存器 原理与使用:DR0-DR7
查看>>
C# MP3文件属性读取
查看>>
团队冲刺06
查看>>
java字节流复制文件
查看>>
重载和覆盖
查看>>
实验二 进程调度预备
查看>>
7zip在DOS命令行用法总结
查看>>
Xcode开发 字符串用法
查看>>
在IIS中实现JSP
查看>>
[转载]Meta标签详解
查看>>
File,FileStream,byte[]3者互相转换总结(转)
查看>>
springboot 使用devtools 实现热部署
查看>>