Cod sursa(job #1310500)
Utilizator | Data | 6 ianuarie 2015 22:04:25 | |
---|---|---|---|
Problema | Sum | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream f("sum.in");
ofstream g("sum.out");
int n,j,suma; //0 <= a <=2 x
f >> n ;
int x;
int a,k;
while (f >> x)
{ suma = 0 ;
for(j=1;j<=2*x;j++)
{ k = j ; a= x ;
while (k!=a) if (a > k) a-=k;
else k-= a;
if (k ==1)
suma += j ;}
g <<suma;
}
return 0;
}