标签:code show name 前缀和 mem nbsp pos number imp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7752 Accepted Submission(s): 3217
1 #include <algorithm> 2 #include <cstdio> 3 4 using namespace std; 5 6 #define LL long long 7 const int N(3000233); 8 LL a,b,phi[N]; 9 10 void All_phi() 11 { 12 for(int i=1;i<=N;i++) 13 phi[i]=i; 14 for(int i=2;i<=N;i++) 15 if(phi[i]==i) 16 for(int j=i;j<=N;j+=i) 17 phi[j]=phi[j]/i*(i-1); 18 } 19 20 int main() 21 { 22 All_phi(); 23 for(int i=1;i<=N+1;i++) phi[i]=phi[i-1]+phi[i]; 24 for(;scanf("%d%d",&a,&b)!=EOF;) 25 printf("%I64d\n",phi[b]-phi[a-1]); 26 return 0; 27 }
HDU——T 2824 The Euler function
标签:code show name 前缀和 mem nbsp pos number imp
原文地址:http://www.cnblogs.com/Shy-key/p/7306564.html