poj 2478 欧拉函数
来源:互联网 发布:java培训班包住 编辑:程序博客网 时间:2024/05/17 03:30
欧拉函数基础之基础题
#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<cmath>#include<algorithm>#include<iomanip>using namespace std;#define Max 1000005int p[Max];int ph[Max]; //记录《=i的且与i互质的个数void prime() //筛选法求素数{ int i,j; memset(p,0,sizeof(p)); p[1]=1; for(i=2;i<Max;i++) { if(p[i]==0) { for(j=i*2;j<Max;j+=i) p[j]=1; } }}void euler(){ int i,j; for(i=0;i<Max;i++) { ph[i]=i; } for(i=2;i<Max;i++) { if(p[i]==0) { for(j=i;j<Max;j+=i) ph[j]=ph[j]/i*(i-1); } }}int main(){ prime(); euler(); int n; while(cin>>n) { if(n==0) break; long long ans=0; for(int i=2; i<=n; i++) ans+=(ph[i]); printf("%lld\n",ans); } return 0;}
- POJ - 2478 欧拉函数..
- poj 2478 欧拉函数
- poj 2478 欧拉函数
- POJ-2478 欧拉函数
- poj 2478 Farey Sequence (欧拉函数)
- poj 2478 Farey Sequence(欧拉函数)
- POJ 2478 Farey Sequence(欧拉函数)
- POJ 2478 : Farey Sequence - 欧拉函数
- POJ-2478(欧拉函数)
- poj 2478 Farey Sequence(欧拉函数)
- poj 2478 欧拉函数筛选
- POJ 2478 Farey Sequence 欧拉函数 .
- POJ 2478 Farey Sequence 欧拉函数
- |poj 2478|欧拉函数|Farey Sequence
- poj 2478 (欧拉函数)
- 欧拉函数:poj 2407, poj 1284,poj 2478,poj 3090,poj 3696,poj 3358
- poj 2773(欧拉函数)
- POJ 2773 欧拉函数
- linux下socket编程(基础参考)
- 使用eclipse进行调试嵌入式Linux程序
- android ViewFlipper的使用
- springside中quickstart项目修改
- 使用urjtag了解WRV54G
- poj 2478 欧拉函数
- Win32中调用其他应用程序的方法(函数)winexec,shellexecute ,createprocess
- 使用openjtag和openocd操作IXP425的flash
- 高效编辑器vim之快速移动
- 在redboot中中加入以太网支持的通用方法
- java实现tree功能
- wordpress 后台添加子菜单 常用的几种情况
- 将openwrt移植到P720
- xmpp muc room