Send a Table 欧拉函数UVA - 10820
2017-06-28 09:42
363 查看
题意:给你个n,问有多少个pair < x,y > ,满足x,y互质。
分析,当x < y的时候,值f(y),就是将1到n的欧拉函数加起来,
当x>y,情况一样,就是倒过来。
只用x=1,y=1,的时候,x==y;
分析,当x < y的时候,值f(y),就是将1到n的欧拉函数加起来,
当x>y,情况一样,就是倒过来。
只用x=1,y=1,的时候,x==y;
#include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <cstdio> using namespace std; const int maxn = 5e4+5; long long phi[maxn]; void phi_table() { int n=50001; for(int i=2;i<=n;i++) phi[i]=0; phi[1]=1; for(int i=2;i<=n;i++) { if(!phi[i]) { for(int j=i;j<=n;j+=i){ if(!phi[j]) phi[j]=j; phi[j]=phi[j]/i*(i-1); } } } } int main() { int n; phi_table(); while(scanf("%d",&n)!=EOF&&n) { long long ans=0; for(int i=2;i<=n;i++) ans+=phi[i]; ans=ans*2+1; printf("%lld\n",ans); } return 0; }
相关文章推荐
- UVa 10820 Send a Table(欧拉函数)
- [UVA 10820]Send a Table[欧拉函数][nloglog(n)]
- Send a Table 欧拉函数UVA - 10820
- UVa-10820 Send a Table 欧拉函数
- UVa 10820 - Send a Table(欧拉函数)
- UVA - 10820 Send a Table 欧拉函数
- UVA 10820 - Send a Table 数论 (欧拉函数)
- Send a Table 欧拉函数UVA - 10820
- UVA - 10820 - Send a Table -(欧拉函数)
- UVa 10820 Send a Table (Farey数列&欧拉函数求和)
- Send a Table 欧拉函数UVA - 10820
- Uva 10820 Send a Table(欧拉函数)
- uva 10820 send a table (欧拉函数)
- Send a Table 欧拉函数UVA - 10820
- UVA 10820 Send a Table(欧拉函数)
- Send a Table 欧拉函数UVA - 10820
- uva10820 - Send a Table 欧拉函数
- UVa 10820 - Send a Table(欧拉函数)
- Send a Table UVA - 10820——欧拉函数初级应用
- UVA 10820 Send a Table (欧拉函数打表)