2 条题解
-
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; LL get_phi(LL x) { LL res=x; for(LL i=2; i*i<=x; i++) if(x%i==0) { res=res/i*(i-1); while(x%i==0) x/=i; } if(x>1) res=res/x*(x-1); return res; } int main() { LL n; scanf("%lld", &n); LL t=sqrt(n+1), ans=0; for(LL i=1; i<=t; i++) if(n%i==0) { ans+=get_phi(n/i)*i; if(i*i!=n) ans+=get_phi(i)*(n/i); } printf("%lld\n", ans); return 0; } -
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; LL get_phi(LL x) { LL res=x; for(LL i=2; i*i<=x; i++) if(x%i==0) { res=res/i*(i-1); while(x%i==0) x/=i; } if(x>1) res=res/x*(x-1); return res; } int main() { LL n; scanf("%lld", &n); LL t=sqrt(n+1), ans=0; for(LL i=1; i<=t; i++) if(n%i==0) { ans+=get_phi(n/i)*i; if(i*i!=n) ans+=get_phi(i)*(n/i); } printf("%lld\n", ans); return 0; }
- 1
信息
- ID
- 4370
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 8
- 标签
- 递交数
- 14
- 已通过
- 8
- 上传者