![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 5 const int maxn = 3000000+100; 6 int phi[maxn]; 7 int a,b; 8 9 void phi_table(int n) 10 { 11 memset(phi,0,sizeof(phi)); 12 phi[1] = 1; 13 for(int i = 2;i <= n;i ++) 14 { 15 if(!phi[i]) 16 { 17 for(int j = i;j <= n;j += i) 18 { 19 if(!phi[j]) 20 phi[j] = j; 21 phi[j] = phi[j] / i * (i - 1); 22 } 23 } 24 } 25 } 26 27 int main() 28 { 29 while(scanf("%d%d",&a,&b) == 2) 30 { 31 phi_table(b); 32 33 __int64 ans = 0; 34 for(int i = a;i <= b;i ++) 35 { 36 ans += (__int64)phi[i]; 37 } 38 39 printf("%I64d\n",ans); 40 } 41 42 return 0; 43 }