Cod sursa(job #1291418)
Utilizator | Data | 12 decembrie 2014 19:30:25 | |
---|---|---|---|
Problema | Sum | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<cstdio>
#define N 100001
using namespace std;
int phi[N+1];
int main()
{ int n,i,j; long long x;
for(i=1;i<=N;i++)phi[i]=i-1;
for(i=2;i<=N;i++)
for(j=2*i;j<=N;j+=i) phi[j]-=phi[i];
freopen("sum.in","r",stdin);
freopen ("sum.out","w",stdout);
scanf("%ld",&n);
while(n--)
scanf("%lld",&x), printf("%lld\n",x*phi[x]*2);
return 0;
}