Cod sursa(job #2480006)

Utilizator _nastea_Popov Anastasia _nastea_ Data 24 octombrie 2019 19:05:07
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb


#include <iostream>
#include <fstream>
using namespace std;
int main()
{
	int n;
	ifstream f("fractii.in");
	f >> n;
	int nr = n * n;
	for(int a=1;a<=n;a++)
		for (int 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;
	g.close();
	return 0;
}