GTW likes function

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 92    Accepted Submission(s): 54

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)

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
//中文题意
问题描述现在给出下列两个定义:f(x)=f0(x)=∑k=0x(−1)k22x−2kC2x−k+1k,fn(x)=f(fn−1(x))(n≥1)f(x)=f_{0}(x)=\sum_{k=0}^{x}(-1)^{k}2^{2x-2k}C_{2x-k+1}^{k},f_{n}(x)=f(f_{n-1}(x))(n\geq 1)f(x)=f​0​​(x)=∑​k=0​x​​(−1)​k​​2​2x−2k​​C​2x−k+1​k​​,f​n​​(x)=f(f​n−1​​(x))(n≥1)φ(n)\varphi(n)φ(n)为欧拉函数。指的是不超过nnn的与nnn互质的正整数个数。对于每组数据,GTW有两个正整数n,xn,xn,x,现在他想知道函数φ(fn(x))\varphi(f_{n}(x))φ(f​n​​(x))的值。
输入描述输入有多组数据,不超过100组。每数据输入一行包含2个整数组nnn和xxx。(1≤n,x≤1012)(1\leq n,x \leq 10^{12})(1≤n,x≤10​12​​)输出描述对于每组数据输出一行,表示函数φ(fn(x))\varphi(f_{n}(x))φ(f​n​​(x))的值。
输入样例1 1
2 1
3 2输出样例2
2
2
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
ll eular(ll n)
{ll i,j,ans=n;for(i=2;i*i<=n;i++){if(n%i==0){ans=ans/i*(i-1);while(n%i==0)n/=i;}}if(n>1)ans=ans/n*(n-1);return ans;
}
int main()
{ll n,x;while(scanf("%lld%lld",&n,&x)!=EOF)printf("%lld\n",eular(n+x+1));return 0;
}

hdoj GTW likes function 5597 (裸欧拉函数)相关推荐

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

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

  2. 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 ...

  3. hdoj 5597 GTW likes function 【打表找规律】

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

  4. hdu5597GTW likes function+欧拉函数

    Problem Description Now you are given two definitions as follows. f(x)=∑xk=0(−1)k22x−2kCk2x−k+1,f0(x ...

  5. HDU 5597 GTW likes function 打表

    GTW likes function 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5596 Description Now you are give ...

  6. HDU 5597 GTW likes function

    题意: 现在给出下列两个定义:f(x)=f_{0}(x)=\sum_{k=0}^{x}(-1)^{k}2^{2x-2k}C_{2x-k+1}^{k},f_{n}(x)=f(f_{n-1}(x))(n\ ...

  7. (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 ...

  8. 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 ...

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

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

最新文章

  1. 2015年二级c语言真题及答案,2015年计算机二级C语言测试题及答案(4)
  2. MySQL:Innodb DB_ROLL_PTR指针解析
  3. Bootstrap组件_按钮组
  4. How product extension field is involved in search scenario
  5. [Intel Edison开发板] 04、Edison开发基于nodejs和redis的服务器搭建
  6. 做Web应用程序时应该如何面向对象杂谈
  7. OpenGL基础28:模型
  8. 《软技能—代码之外的生存指南》
  9. Web服务器基础详解
  10. (转载)PHP环境搭建-记录
  11. java 对手机号码进行校验
  12. oracle全量拷贝,oracle数据库expdp异机全量备份
  13. 看完你就知道交换机端口该搭配什么光模块了
  14. html在表格输入文字不显示,Word表格中有部分格子内无法输入文字是怎么回事?...
  15. codeforces gym101482 J Judging Troubles 暴力+map
  16. 计算机的问卷调查的题目,新颖的调查问卷的题目
  17. 【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
  18. 在家用手机兼职稳定收入,三种实战方法
  19. ¥1-2 例2.2 将两个集合的并集放到线性表中
  20. Java集合是什么?

热门文章

  1. 华为设备MUX VLAN配置命令
  2. python十进制小数转二进制_在python中如何将十进制小数转换成二进制
  3. php识别脸型代码,PHP人脸识别为你的颜值打分
  4. 推荐一款我喜欢的代码主题风格
  5. 个人软件开发委托书范本
  6. 2021亚太杯C题全网最全解题思路+塞罕坝林场数据数据分享
  7. 十四. 项目人力资源管理
  8. EOL while scanning string literal的问题解决
  9. python title函数用法_python函数用法
  10. 名词性从句 - 主语从句