Cod sursa(job #274752)
Utilizator | Data | 9 martie 2009 22:50:02 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.03 kb |
#include<fstream.h>
#include<math.h>
long n,i,j,s,ci,cj,r;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int main()
{
fin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
ci=i;
cj=j;
if(ci%cj)
{
if(ci>cj)
{
do
{
r=ci%cj;
ci=cj;
cj=r;
}
while(r);
if(ci==1)
s++;
}
else
{
do
{
r=cj%ci;
cj=ci;
ci=r;
}
while(r);
if(cj==1)
s++;
}
}
}
}
fout<<s;
return 0;
}