GTW likes function

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

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 题意:应该都能看懂就不翻译了 思路:其实这个挺简单的,列几组数据,然后就会发现往下递归几次最后num就是加上了几+1,也就是说num的变化值 为n+1,而num的初始值呢,当你列出几组数据会发现,x=1的时候num=1,x=2的时候,num=2;,所以说最后的 num=x+n+1,所以ans=eular(num)。。。 ac代码:

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 60001
#define LL long long
#define INF 0xfffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
using namespace std;
LL eular(LL n)
{  LL i,res=n;  for(i=2;i*i<=n;i++)  if(n%i==0){  res=res/i*(i-1);  while(n%i==0)n/=i;  }  if(n>1) res=res/n*(n-1);  return res;
}
int main()
{LL n,x;while(scanf("%I64d%I64d",&n,&x)!=EOF){printf("%I64d\n",eular(n+x+1));}return 0;
}

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

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

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

  2. hdu5597GTW likes function+欧拉函数

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

  3. 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 简单证 ...

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

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

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

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

  8. HDU 5597 GTW likes function 打表

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

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

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

最新文章

  1. C++ 笔记(25)— 理解 C++ 中的头文件和源文件的作用
  2. 小功率荧光灯拆解分析
  3. 扇出性 java_索引与算法
  4. 算法笔记(JavaScript版)——排序
  5. spring-6、动态代理(cglib 与 JDK)
  6. 我们应该搞清楚分支预测
  7. LeetCode MySQL 180. 连续出现的数字(cast)
  8. 徐汉字java字符_汉字徐的拼音部首-汉字徐的笔画和解释-汉字徐在线查新华字典...
  9. Easy Recovery帮你解决数据丢失的苦恼
  10. 【转】细说@Html.ActionLink()的用法
  11. dw向右滚动字幕HTML,[转载]DW添加滚动字幕[转]
  12. python中没有严格意义上的私有成员_尔雅尔雅学习通APP家园的治理:环境科学概论题库及答案...
  13. python多边形的绘制教程_使用Python matplotlib绘制3D多边形
  14. Delphi XE2控件安装方法
  15. element-ui 图标太少解决方案
  16. linux如何永久获取root,Linux如何获取root权限?我只想到这些方法了,欢迎补充
  17. 虚拟机 Ubuntu 14.04 LTS (64 bits) 下安装 Kurento v6 并运行 kurento-hello-world
  18. Android 银行卡快捷支付
  19. Android组件安全
  20. NFT游戏开发元宇宙游戏开发游戏源码+搭建

热门文章

  1. 网络安全行业需要学历吗?需要考研吗?
  2. 安装MySQL5.7时卡在starting server。the configuration step starting server is taking longer than expected
  3. python运维必须会用的库
  4. java银行管理系统ui_java毕业设计_springboot框架的商业银行管理平台
  5. 官媒:发挥数字货币的正能量,服务于实体经济
  6. 【CAJ转PDF】利用CAJ云阅读将CAJ转换成PDF
  7. matplotlib画图自定义marker
  8. (Pycharm新版专业版)初次部署无法同步文件,报错信息:找不到要处理的文件或文件夹
  9. 数据库中 码、候选码、主码 的区别
  10. 图的十字链表存储法详解