Pagini recente » Cod sursa (job #3154738) | Cod sursa (job #1982019) | Borderou de evaluare (job #2165450) | Diferente pentru problema/chocolate intre reviziile 8 si 9 | Cod sursa (job #2480007)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("fractii.in");
int n, nr = n * n, a, b;
f >> n;
for (a = 1; a <= n; a++)
{
for (b = 1; b <= n; b++)
{
int x = a, y = b;
while (x != y)
if (x > y)
x = x - y;
else
y = y - x;
if (x != 1)
nr--;
}
}
ofstream g("fractii.out");
g << nr;
return 0;
}