Cod sursa(job #559418)

Utilizator thelasMatei Vlad thelas Data 17 martie 2011 20:13:45
Problema Sum Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include<iostream>
#include<fstream>
using namespace std;
int p(int a, int b)
{int d;
if(a!=b)
{
do
{if (a>b)
	a=a-b;
if(b>a)
	b=b-a;
d=a;}
while(a!=b);}
else 
	d=0;
return d;}
int main()
{int S,x,n,i;
ifstream f("a.in");
ofstream g("a.out");
f>>n;
do
{f>>x;
S=0;
for (i=1;i<=x*2;i++)
	if (p(x,i)==1)
	S=S+i;
n--;
g<<S<<'\n';}
while(n!=0);
g.close();
f.close();
}