Cod sursa(job #134181)
Utilizator | Data | 10 februarie 2008 20:28:54 | |
---|---|---|---|
Problema | Sum | Scor | 45 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<fstream.h>
ifstream fin("sum.in");
ofstream fout("sum.out");
long x,N,i,j;
long s;
int cmmdc(long a, long b)
{
while(a!=b) { if(a>b) a-=b; else b-=a; }
return b;
}
int main()
{
fin>>N;
for(i=1; i<=N; i++)
{ fin>>x;
s=0;
for(j=1; j<=2*x; j++)
if(cmmdc(j,x)==1) s+=j;
fout<<s<<"\n";
}
return 0;
}