POJ 3090 Visible Lattice Points 法雷级数
2014-05-12 11:14
363 查看
题目来源:POJ 3090 Visible Lattice Points
题意:哪些点可以看到
思路:
法雷级数 可以看到的那些点就是法雷级数对应的分数
法雷级数的个数可以由欧拉函数求出
题意:哪些点可以看到
思路:
F1: 0/1 1/1 F2: 0/1 1/2 1/1 F3: 0/1 1/3 1/2 2/3 1/1 F4: 0/1 1/4 1/3 1/2 2/3 3/4 1/1 F5: 0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1 F6:0/1 1/6 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 5/6 1/1
法雷级数 可以看到的那些点就是法雷级数对应的分数
法雷级数的个数可以由欧拉函数求出
#include <cstdio> #include <cstring> #include <cmath> //欧拉phi函数 const int maxn = 1000010; typedef long long LL; int euler_phi(int n) { int m = sqrt(n+0.5); int ans = n; for(int i = 2; i <= m; i++) { if(n % i == 0) { ans = ans / i * (i-1); while(n % i == 0) n /= i; } } if(n > 1) ans = ans / n * (n-1); return ans; } LL phi[maxn]; void phi_table(int n) { 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() { phi_table(1000); for(int i = 2; i <= 1000; i++) phi[i] += phi[i-1]; int T, cas = 1; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); printf("%d %d %lld\n", cas++, n, phi *2+1); } return 0; }
相关文章推荐
- poj3090 Visible Lattice Points(法雷级数)
- poj 3090 Visible Lattice Points 法雷级数||打表
- 法雷级数(poj 3090 Visible Lattice Points)
- POJ 3090 Visible Lattice Points (ZOJ 2777)
- POJ 3090 Visible Lattice Points (欧拉函数)
- POJ-3090 Visible Lattice Points
- (Relax 数论1.9)POJ 3090 Visible Lattice Points(欧拉函数的应用:计算前n项欧拉数之和)
- POJ 3090 Visible Lattice Points
- 【POJ】3090 Visible Lattice Points 欧拉函数
- POJ 3090 Visible Lattice Points
- POJ 3090 Visible Lattice Points
- POJ 3090 Visible Lattice Points (欧拉函数)
- POJ 3090 Visible Lattice Points 欧拉函数运用
- zoj 2777 || poj 3090 Visible Lattice Points
- POJ 3090 Visible Lattice Points
- POJ3090_Visible Lattice Points【欧拉函数】
- poj Visible Lattice Points(3090)
- poj 3090 Visible Lattice Points
- Visible Lattice Points POJ - 3090 (欧拉函数筛)
- POJ 2478 Farey Sequence & POJ 3090 Visible Lattice Points (欧拉函数)