题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5597
题意:
http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=658&pid=1003
题解:
f0(1)=2; f0(2)=3; f0(3)=4;
f1(1)=3; f1(2)=4; f1(3)=5;
f2(1)=4; ......
所以归纳出:fn(x)=n+x+1; orz
然后求euler(n+x+1).
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL; LL euler_phi(LL x) {
LL ret = x;
for (LL i = ; i*i <= x; i++) {
if (x%i == ) {
ret = ret / i*(i - );
while (x%i == ) x /= i;
}
}
if (x > ) ret = ret / x*(x - );
return ret;
} int main() {
LL n, x;
while (scanf("%lld%lld", &n, &x) == && n) {
printf("%lld\n", euler_phi(n + x + ));
}
return ;
}