Pagini recente » Cod sursa (job #2528733) | Cod sursa (job #1563298) | Cod sursa (job #1360215) | Cod sursa (job #2000328) | Cod sursa (job #3123235)
#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("euclid2.in", "r", stdin);
freopen("euclid2.out", "w", stdout);
cin >> tests;
for (int test = 0; test < tests; test++) {
cin >> x >> y;
cout << gcd(x, y) << "\n";
}
return 0;
}