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