UVA 10820 Send a Table(欧拉函数)
来源:互联网 发布:miui优化 编辑:程序博客网 时间:2024/04/29 17:04
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1761
大意:输入两个整数(1<=x,y<=n),输出函数f(x,y),函数有这样的性质,可以由f(x,y)得到f(k*x,k*y)。问至少需要多少个f(x,y)能得到所有的函数值。
分析,函数的性质告诉我们它和神奇的GCD很像,问题就是求解1—n中有多少对数字互质。欧拉函数值得拥有.
#include <iostream>#include <cstdio>using namespace std;const int N=5e4+5;typedef long long LL;int phi[N];void getphi(){ for(int i=1;i<N;i++) phi[i]=i; for(int i=2;i<N;i++){ if(phi[i]==i){ for(int j=i;j<N;j+=i){ phi[j]=phi[j]-phi[j]/i; } } }}int main(){ int n; getphi(); while(cin>>n&&n){ LL ans=0; for(int i=2;i<=n;i++) ans=ans+phi[i]; cout<<2*ans+1<<endl; } return 0;}
0 0
- UVA 10820 - Send a Table 数论 (欧拉函数)
- uva 10820 - Send a Table(欧拉函数)
- UVa 10820 - Send a Table(欧拉函数)
- UVA - 10820 - Send a Table (欧拉函数)
- UVa 10820 - Send a Table(欧拉函数)
- UVA 10820 Send a Table(欧拉函数)
- UVA 10820 Send a Table(欧拉函数)
- Send a Table 欧拉函数UVA
- 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[欧拉函数][nloglog(n)]
- uva 10820 send a table (欧拉函数)
- UVA 10820 Send a Table (欧拉函数打表)
- uva 10820 Send a Table 欧拉函数
- 简笔画~公鸡
- 220,抽屉效果
- win7虚拟机里面windows xp上网设置问题
- 人工智能和机器学习领域开源项目
- LeetCode17. Letter Combinations of a Phone Number
- UVA 10820 Send a Table(欧拉函数)
- 创意的市场因素
- 创意的市场因素
- 简笔画~鸭子
- R下的GUI方案
- 221,多线程基础
- 简笔画~猴子
- 关于区块链的一些思考
- 注解