Cod sursa(job #318219)
Utilizator | Data | 27 mai 2009 17:48:44 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<iostream.h>
#include<fstream.h>
unsigned long n,p,q,aux,r,aux1,p1,q1;
main()
{ fstream f("fractii.in",ios::in);
fstream g("fractii.out",ios::out);
f>>n;
for(p=1;p<=n;p++)
{
for(q=1;q<=n;q++)
{q1=q;
p1=p;
if(p1<q1)
{aux1=p1;
p1=q1;
q1=aux1;
}
while(q1!=0)
{
r=p1%q1;
p1=q1;
q1=r;
}
if(p1==1)
aux++;
}
}
g<<aux;
}