Cod sursa(job #2775753)

Utilizator cs2323blackbluegrey cs2323 Data 16 septembrie 2021 22:44:16
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.36 kb
#include<iostream>
#include<fstream>
using namespace std;

int main(){
	
	ifstream f("fractii.in");
	ofstream g("fractii.out");
	int n, s = 0;
	f >> n;
	for(int i = 1; i <= n; i++)
	{for(int j = 1; j <= n; j++)
	{
		int x = i, y = j;
	    while(x != y){
		if(x > y) x -= y;
		else y -= x;
	}
	if(x == 1) s++;
	} }
	g << s;
	f.close();
	g.close();
}