Cod sursa(job #240402)
| Utilizator | Data | 7 ianuarie 2009 16:41:55 | |
|---|---|---|---|
| Problema | Sum | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<stdio.h>
#include<math.h>
int main()
{
long d,N,i,e,cx,lim,s,x,phi;
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%ld",&N);
for (i=1;i<=N;i++)
{
scanf("%ld",&x);
phi=x;
cx=x;
d=2;
lim=sqrt(x)+1;
while(x>1&&d<=lim)
{
e=0;
while(x%d==0)
{e++;x/=d;}
if (e)
{
phi=phi/d;
phi=phi*(d-1);
}
d++;
}
s=2*cx*phi;
printf("%ld\n",s);
}
return 0;
}