Cod sursa(job #980674)
| Utilizator | Data | 5 august 2013 14:05:51 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <iostream>
#include <cstdio>
using namespace std;
#define MAXN 100010
int PHI[MAXN];
void preproc()
{
PHI[1] = 1;
for(int i = 2; i <= MAXN; i++)
{
PHI[i] = i - 1;
}
for(int i = 2; i < MAXN; i++)
{
for(int j = 2 * i; j < MAXN; j += i)
{
PHI[j] -= PHI[i];
}
}
}
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
int n,x;
preproc();
scanf("%d",&n);
while(n--)
{
scanf("%d",&x);
long long s=1LL * PHI[x] * x *2 ;
printf("%lld\n",s);
}
return 0;
}
