Cod sursa(job #879722)
Utilizator | Data | 15 februarie 2013 20:01:30 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<fstream>
using namespace std;
int ireductibile(int x, int y)
{int r;
while(y)
{r=x%y;
x=y;
y=r;
}
return x;
}
int main()
{int i,n,k=0,j,rez;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin>>n;
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
{rez=ireductibile(i,j);
if(rez==1)
k++;
}
}
fout<<k;
}