UVA - 10820 - Send a Table
来源:互联网 发布:ggplot2 python 编辑:程序博客网 时间:2024/04/26 11:39
题意:1 <= x, y <= n,可以根据 f(x0, y0)得知 f(k * x0, k * y0) ,问最简要得知所有的f(x,y)至少需要统计多少x与y?
可以看出,实质就是与,n以内有多少对互素的元素,利用欧拉函数即可。
#include<cstdio>#include<cstring>#include<cctype>#include<cstdlib>#include<cmath>#include<iostream>#include<sstream>#include<iterator>#include<algorithm>#include<string>#include<vector>#include<set>#include<map>#include<deque>#include<queue>#include<stack>#include<list>typedef long long ll;typedef unsigned long long llu;const int MAXN = 100 + 10;const int MAXT = 50000 + 10;const int INF = 0x7f7f7f7f;const double pi = acos(-1.0);const double EPS = 1e-6;using namespace std;int a[MAXT], phi[MAXT];//欧拉函数打表void phi_table(){ memset(phi, 0, sizeof phi); phi[1] = 1; for(int i = 2; i < MAXT; ++i) if(!phi[i]) for(int j = i; j < MAXT; j += i){ if(!phi[j]) phi[j] = j; phi[j] = phi[j] / i * (i - 1); } for(int i = 3; i < MAXT; ++i) phi[i] += phi[i - 1];}int main(){ phi_table(); int n; while(scanf("%d", &n) == 1 && n){ if(n == 1) printf("1\n"); else printf("%d\n", 2 * phi[n] + 1); } 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
- 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
- UVA 10820 Send a Table
- Send a Table UVA
- Send a Table UVA
- UVA 10820 Send a Table euler_phi函数
- 盲打小记
- UVA - 11093 - Just Finish it up
- 2014 北京区域赛 F Fluorescent HDU5117 (数学+状压+dp)
- executable binary cannot run on android marshmallow (android 6.0)
- Java之JFrame
- UVA - 10820 - Send a Table
- javascript的原型
- jQuery
- 2.3 进程同步
- springboot mysql 乱码
- java 变量类型各种转换大整合
- 用内存做缓存
- RPC(远程过程调用)简介
- UISearchBar