Cod sursa(job #1348069)
Utilizator | Data | 19 februarie 2015 14:59:30 | |
---|---|---|---|
Problema | Sum | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");
bool PIE(int a,int b)
{
int r;
while(b)
{
r=a%b;
a=b;
b=r;
}
if(a==1) return 1;
else return 0;
}
int main()
{
int n,i,x,j,s,t;
in>>n;
for(i=1;i<=n;i++)
{
in>>x;
s=0;
t=2*x;
for(j=1;j<=t;j++) if(PIE(x,j)) s+=j;
out<<s<<"\n";
}
return 0;
}