Problem 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) f(x)=∑^x_{k=0}(−1)^k2^{2x−2k}C^k_{2x−k+1},f_0(x)=f(x),f_n(x)=f(f_{n−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≤10^12)

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

Source
BestCoder Round #66 (div.2)

f0(1)=2,f0(2)=3 f_0(1)=2,f_0(2)=3
f1(1)=3,f1(2)=4 f_1(1)=3,f_1(2)=4
f2(1)=4,f2(2)=5 f_2(1)=4,f_2(2)=5
so..猜一发 fn(x)=n+x+1 f_n(x)=n+x+1
直接求欧拉函数就好。。

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3fLL eular(LL n){LL ans=n;for(LL i=2;i*i<=n;i++){if(n%i==0){ans-=ans/i;while(n%i==0) n/=i;}}if(n>1) ans-=ans/n;return ans;
}
int main(){ios::sync_with_stdio(false);LL n,x;while(cin>>n>>x){cout<<eular(n+x+1)<<endl;}return 0;
}

hdu5597GTW likes function+欧拉函数相关推荐

  1. hdu 5597GTW likes function(欧拉函数)

    题目链接:[hdu 5597] f(n)=sum((-1)^k * 2^(2n-2k) * C(k, 2n-k+1))   0<=k<=n 这个公式化简之后就是f(x) = x+1 简单证 ...

  2. XTU OJ 1355 Euler‘s Totient Function(欧拉函数)

    XTU OJ 1355 Euler's Totient Function(欧拉函数) 题目描述 对于整数n,定义ϕ(n)ϕ(n)ϕ(n)为小于或等于n,并与n互质的整数的个数,比如6,比它小的和它互质 ...

  3. (hdu step 7.2.1)The Euler function(欧拉函数模板题——求phi[a]到phi[b]的和)

    题目: The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...

  4. hdoj GTW likes function 5597 (裸欧拉函数)

    GTW likes function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Oth ...

  5. HDU 5597 GTW likes function(规律+欧拉函数模板题)——BestCoder Round #66(div.1 div.2)

    GTW likes function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Oth ...

  6. UVA10990 Another New Function【欧拉函数打表】

    The depth of phi value of a number is denoted by the number of steps required before it reaches 1. A ...

  7. HDU6322 Problem D. Euler Function【欧拉函数+数学规律】

    Problem D. Euler Function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java ...

  8. 一欧拉函数(Euler‘s totient function)

    算法总结 一欧拉函数(Euler's totient function) 欧拉函数的定义: 在数论中,对于正整数N,少于或等于N ([1,N]),且与N互质的正整数(包括1)的个数,记作φ(n). φ ...

  9. poj2154-color-polyan次二面体+欧拉函数优化

    N<=1e9,O(nlogn)的做法会超时.从枚举置换转变为枚举轮换长度,然后可以利用欧拉函数,把复杂度变为O(√n * logn) 1 /*-------------------------- ...

最新文章

  1. 蓝桥杯C++ AB组辅导课
  2. 来客推多用户商城源码哪里下载?多用户多商城模式有哪些盈利模式?
  3. 轻雀世界知名体育用品零售商D的交流与思考
  4. 3.软件开发的本质和基本手段
  5. Spring Mobile 1.1.0.RC1 和 1.0.2 发布
  6. IFrame标签的两个用法介绍
  7. css 滤镜之AlphaImageLoader
  8. 项目管理工具maven
  9. Emacs收发email
  10. 惠普笔记本被政府盖章存隐藏键盘记录器,怎么回事?
  11. 3D变化——旋转的立方体
  12. PostgreSql扩展(EXTENSION )
  13. c语言写莫迪康通信,组态王modbus通信用法教程modbus-rtu、modbus-tcp莫迪康通信配置步骤...
  14. 程序员教你不背单词学英语!流利英语一周成!!!
  15. 实验三 vi编辑器(Linux基础教程)
  16. 南京大学计算机专业拂晓,南京大学2020年计算机学科录取推免生222人,全部来自211高校...
  17. 四平方和定理(每个正整数均可表示为4个平方数的和)
  18. 【啃书】【阿里云天池大赛赛题解析】目录
  19. 贝叶斯网络实例(python)
  20. Photo Album: 8.14 庞贝-那不勒斯

热门文章

  1. 计算机显卡怎么拨下来,电脑显卡怎么拆
  2. 什么样的_BUG_会让你目瞪口呆?
  3. TortoiseSVN下载安装及配置中文语言包
  4. html怎么引用小图标,Css引用图标方法.html
  5. [安装] Oracle19c rac集群安装
  6. DTLS-SRTP协议学习
  7. easychallenge
  8. CUDA Graph图详解
  9. 透过日播放量超过6亿的《延禧攻略》,看2018视频网站格局(附代码)
  10. VMware15安装macOS Mojave 10.14.6(18G87)