Cod sursa(job #673218)
Utilizator | barbu andrei andrei99 | Data | 4 februarie 2012 09:08:28 |
---|---|---|---|
Problema | Sum | Scor | 45 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<cstdio>
using namespace std;
long unsigned n,x,y,index,i,a,b,suma;
FILE *f1,*f2;
int main()
{
f1=freopen("sum.in","r",stdin);
scanf("%lu",&n);
f2=freopen("sum.out","w",stdout);
for(index=0;index<n;index++)
{
scanf("%lu",&x);
suma=1;
for(i=2;i<2*x;i++)
{
a=i;
b=x;
while(a!=b)
if(a>b)
a=a-b;
else
b=b-a;
if(a==1)
suma=suma+i;
}
printf("%lu\n",suma);
}
fclose (f1);
fclose (f2);
return 0;
}