Cod sursa(job #366710)
Utilizator | Data | 22 noiembrie 2009 10:25:47 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include<iostream.h>
#include<fstream.h>
fstream in("fractii.in",ios::in), out("fractii.out",ios::out);
int cmmdc(long a,long b)
{ while (a!=b)
if(a>b) a=a-b;
else b=b-a;
return a;
}
main()
{
long n,i,j,x=0,y;
in>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{if(i%2==0 && j%2==1) j++;
y=cmmdc(i,j);
if (y==1) x++;
}
out<<x;
}