Cod sursa(job #1659984)
Utilizator | Data | 22 martie 2016 18:57:56 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
long N;
int i,j,sol;
long cmmdc (long x, long y) {
while (x!=y)
if (x>y) x=x-y;
else y=y-x;
return x;
}
int main()
{ f>>N;
for (i=1;i<=N;i++)
for (j=1;j<=N;j++)
if (cmmdc(i,j)==1) sol++;
g<<sol;
f.close();
g.close();
return 0;
}