Cod sursa(job #2191783)
| Utilizator | Data | 3 aprilie 2018 18:20:21 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <cstdio>
using namespace std;
const int N=1000000;
int n;
int phi[N+5];
long long sol;
void build(){
for(int i=1;i<=n;i++)
phi[i]=i;
for(int i=2;i<=n;i++){
if(phi[i]==i)
for(int j=i;j<=n;j+=i){
phi[j]/=i;
phi[j]*=(i-1);
}
sol+=phi[i];
}
}
int main(){
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
scanf("%d",&n);
build();
printf("%lld",2*sol+1);
return 0;
}
