Cod sursa(job #3123234)
Utilizator | Data | 22 aprilie 2023 17:39:22 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <cstdio>
using namespace std;
int tests, x, y;
int gcd(int x, int y) {
int rem;
while (y) {
rem = x % y;
x = y;
y = rem;
}
return x;
}
int main()
{
freopen("euclid.in", "r", stdin);
freopen("euclid.out", "w", stdout);
cin >> tests;
for (int test = 0; test < tests; test++) {
cin >> x >> y;
cout << gcd(x, y) << "\n";
}
return 0;
}