Cod sursa(job #3325255)

Utilizator t-13Fira Rares t-13 Data 25 noiembrie 2025 09:00:50
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.31 kb
#include<fstream>
using namespace std;

int main() {
	ifstream fin("euclid2.in");
	ofstream fout("euclid2.out");
	int tests;
	fin >> tests;
	while (tests--) {
		int a, b, r;
		fin >> a >> b;
		if (b > a) swap(a, b);
		while (b) {
			r = a % b;
			a = b;
			b = r;
		}
		fout << a << '\n';
	}
	
}