题意:
有中文题面
分析:
打表发现f0(x)=x+1,所以fn(x)=n+x+1
证明见bc题解
打表的重要性!
代码:
//
// Created by TaoSama on 2015-12-12
// Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
using namespace std;
#define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
typedef long long LL;
LL n, x;
LL euler(LL x) {
LL ret = x, t = x;
for(int i = 2; i * i <= x; ++i) {
if(t % i == 0) {
ret = ret / i * (i - 1);
while(t % i == 0) t /= i;
}
}
if(t > 1) ret = ret / t * (t - 1);
return ret;
}
int main() {
#ifdef LOCAL
freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
// freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
ios_base::sync_with_stdio(0);
while(scanf("%I64d%I64d", &n, &x) == 2) {
printf("%I64d\n", euler(n + x + 1));
}
return 0;
}