POJ 3090 : Visible Lattice Points - 欧拉函数
来源:互联网 发布:义乌淘宝网店摄影培训 编辑:程序博客网 时间:2024/06/08 08:45
题意:
称 线段可见 当且仅当 从点(0,0)到(x,y)不经过其他整点。
给出一个可见点N,计算在区域0<=x<=N,0<=y<=N内可见点的数目。
分析:
线段可见 即 x,y不可以约分,即x,y互素。
问题即可转化为求1~n内互素的数的对数,即可通过求1~n的欧拉函数值解决。
同前一个题目一样,打表预处理。
0ms G++
#include<iostream>#include<cstdio>#include<cstdlib>#define LL long longusing namespace std;const int N=1000;int main(){LL phi[N+1];int i,j,t,n;for(i=1;i<N+1;i++){if(i%2==1) phi[i]=i;else phi[i]=i/2;}for(i=3;i<N+1;i+=2)if(phi[i]==i){for(j=i;j<N+1;j+=i)phi[j]=phi[j]/i*(i-1);}for(i=2;i<N+1;i++)phi[i]+=phi[i-1];scanf("%d",&t);for(i=1;i<=t;i++){scanf("%d",&n);printf("%d %d %lld\n",i,n,phi[n]*2+1);}return 0;}
0 0
- 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 (欧拉函数)
- 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 欧拉函数
- poj 3090 Visible Lattice Points (欧拉函数)
- Visible Lattice Points - POJ 3090 欧拉公式
- Visible Lattice Points (欧拉函数)
- Visible Lattice Points 欧拉函数应用
- POJ 2478 Farey Sequence & POJ 3090 Visible Lattice Points (欧拉函数)
- POJ 3090 Visible Lattice Points(Farey数列&欧拉函数求和)
- POJ 3641 : Pseudoprime numbers - 米勒罗宾素数测试
- POJ 2407 : Relatives - 欧拉函数
- POJ 1284 : Primitive Roots - 欧拉函数,原根
- 黑马程序员java基础之io流中的其他流
- POJ 2478 : Farey Sequence - 欧拉函数
- POJ 3090 : Visible Lattice Points - 欧拉函数
- iOS Splash以及更新提示
- POJ 2992 : Divisors - 求组合数的因子个数
- java写文件时,输出不完整的原因以及解决方法close()或flush()
- POJ 2480 : Longge\'s problem - gcd之和
- POJ 3696 : The Luckiest number - 欧拉函数,快速幂[数论好题]
- POJ 2183 : Bovine Math Geniuses - 平方取尾法
- POJ 1107 : W\'s Cipher - 密码,字符串模拟
- POJ 2159 : Ancient Cipher - 密码模拟