Cod sursa(job #1391833)
Utilizator | Laszlo Janos janoslaszlo | Data | 18 martie 2015 10:46:36 |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int n,total,r,a,b;
ifstream f_in("fractii.in");
ofstream f_out("fractii.out");
f_in >> n;
total = n * n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
{
a = i;
b = j;
r = a % b;
while (r != 0)
{
a = b;
b = r;
r = a % b;
}
if (b != 1)
total--;
}
f_out << total;
f_in.close();
f_out.close();
return 0;
}