HDU 2824 The Euler function 欧拉函数
2013-12-15 11:57
323 查看
欧拉函数裸题,直接上代码:
转载注明出处:http://blog.csdn.net/u011400953
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<vector> using namespace std; #define MAX 3000100 int p[MAX],ans[MAX]; bool a[MAX]; int A,B; int main() { //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); int num=0; for(int i=2;i<=3000001;i++) { if(!a[i]) { p[num++]=i; ans[i]=i-1; } for(int j=0;j<num && p[j]*i<=3000001;j++) { a[p[j]*i]=true; if(!(i%p[j])) { ans[i*p[j]]=ans[i]*p[j]; break; } else ans[i*p[j]]=ans[i]*(p[j]-1); } } while(scanf("%d%d",&A,&B)!=EOF) { __int64 ans1=0; for(int i=A;i<=B;i++) ans1=ans1+ans[i]; printf("%I64d\n",ans1); } //system("pause"); return 0; }
转载注明出处:http://blog.csdn.net/u011400953
相关文章推荐
- HDU 2824 The Euler function (欧拉函数打表)
- hdu 2824 The Euler function (欧拉函数离线模板)
- 欧拉函数 & 【POJ】2478 Farey Sequence & 【HDU】2824 The Euler function
- hdu 2824 The Euler function(欧拉函数)
- hdu 2824 The Euler function 欧拉函数模板题
- HDU:2824 The Euler function(欧拉函数)
- hdu 2824 The Euler function(欧拉函数)
- hdu-2824 The Euler function(欧拉函数)
- 【HDU 2824 The Euler function】+ 欧拉函数
- HDU - 2824 -The Euler function【欧拉函数前缀和】
- hdu 2824 The Euler function(欧拉函数)
- hdu 2824 The Euler function 欧拉函数打表
- HDU2824--The Euler function(欧拉函数)
- HDU-#2824 The Euler function(欧拉函数+筛法)
- HDU 2824 The Euler function(欧拉函数)
- HDU 2824 The Euler function【欧拉函数 打表】
- HDU 2824(The Euler function)欧拉函数
- HDU 2824 The Euler function(欧拉函数)
- hdu 2824 The Euler function(欧拉函数)
- HDU 1787 GCD Again/HDU 2824 The Euler function(欧拉函数模板)