Cod sursa(job #149358)
| Utilizator | Data | 5 martie 2008 17:04:56 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include<stdio.h>
FILE *fin=freopen("fractii.in","r",stdin),
*fout=freopen("fractii.out","w",stdout);
const long Nmax=1000002;
long long phi[2*Nmax];
long n;
void totient()
{
for (long i = 1; i <= n; ++i)
phi[i] = i-1;
for (long i = 2; i <= n; ++i)
for (long j = 2*i; j <= n; j += i)
phi[j] -= phi[i];
}
int main()
{
long long s=0;
scanf("%d",&n);
totient();
for(int i=2;i<=n;i++)
s+=phi[i];
printf("%lld",2*s+1);
return 0;
}
