杭电5597
来源:互联网 发布:手机号码群发短信软件 编辑:程序博客网 时间:2024/06/08 02:18
GTW likes function
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 205 Accepted Submission(s): 112
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)) .
Note that
For each test case, GTW has two positive integers —
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)
Each line of the input file indicates a test case, containing two integers,
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 12 13 2
Sample Output
222
Source
BestCoder Round #66 (div.2)
Recommend
hujie | We have carefully selected several similar problems for you: 5599 5598 5596 5594 5593
下次就不证明了,听说大牛都是打表得到的规律,fn(x)=x+n+1;这个但是很容易得到:
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;long long ac(long long n){long long res=n;long long a=n;for(long long i=2;i*i<=a;i++){if(a%i==0)res=res/i*(i-1);while(a%i==0)a/=i;}if(a>1)res=res/a*(a-1);return res;}int main(){long long m,n;while(scanf("%I64d%I64d",&m,&n)!=EOF){long long ans=ac(m+n+1);printf("%I64d\n",ans);}}
1 0
- 杭电5597
- 杭电-5597
- 杭电
- 杭电
- 杭电
- 杭电5597GTW likes function
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- 杭电ACM1061Rightmost Digit
- 杭电2099 7.11
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电ACM1466
- 杭电ACM1003
- 杭电ACM1225
- 杭电ACM2023
- 杭电ACM2602
- 杭电ACM2955
- Android ViewPager嵌套ViewPager滑动冲突的解决方法
- 读书笔记-Android开发艺术探索-第15章-Android性能优化
- Android ListView getView方法和调优 解释
- 计算机图形学知识点复习总结
- tiny4412emmc烧录u-boot, 支持fastboot模式烧写emmc
- 杭电5597
- vmware workstation的克隆与复制
- This qt version uses an unsupported makefile generator object reference not set to an instance of an
- ScrollView嵌套ListView问题的解决方案
- java成长指南
- Android 内存溢出 内存泄漏(二)
- 链表之删除双链表倒数第K个节点
- 利用dbms_system包SET_SQL_TRACE_IN_SESSION开启sql跟踪
- OTL实战小结