Cod sursa(job #1447109)
| Utilizator | Data | 3 iunie 2015 17:48:57 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <stdio.h>
const int n_max = 100010;
const int N = 100010;
long long phi[n_max];
int main()
{
long long i, j, n, t;
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
for (int i=1;i<=N;i++)
phi[i]=i;
for (int i=2;i<=N;i++)
if (phi[i]==i)
for (j=i;j<=N;j+=i)
{
phi[j] /=i;
phi[j] *= (i-1);
}
scanf("%lld", &t);
for (i = 1; i <= t; ++ i)
{
scanf(" %lld ",&n);
printf("%lld\n", 2*n*phi[n]);
}
return 0;
}
