Cod sursa(job #119956)
| Utilizator | Data | 3 ianuarie 2008 18:19:57 | |
|---|---|---|---|
| Problema | Sum | Scor | 45 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream.h>
using namespace std;
int main()
{ long long n,i,s,x,j,cj,r,copie;
ifstream f1("sum.in");
ofstream f2("sum.out");
f1>>n;
for (i=1;i<=n;i++)
{
f1>>x;
s=1;
for (j=2;j<2*x;j++)
{
copie=x;
cj=j;
if ((x%2!=0 || j%2!=0) && (x%3!=0 || j%3!=0))
while(x%j!=0)
{
r=x%j;
x=j;
j=r;
}
else j=0;
if (j==1) s=s+cj;
j=cj;
x=copie;
}
f2<<s<<"\n";
}
return 0;
}
