Pagini recente » Cod sursa (job #2296017) | Cod sursa (job #3310657) | Cod sursa (job #3330679) | Cod sursa (job #3320993) | Cod sursa (job #3316487)
#include <bits/stdc++.h>
using namespace std;
// !!!
string PREFIX = "euclid2";
int get_gcd(int x, int y) {
if (x == 0) return y;
if (y == 0) return x;
int common = 1;
// acum ambele numere sunt impare.
if (x < y) swap(x, y);
return common * get_gcd(x - y, y);
}
int main()
{
ifstream cin(PREFIX + ".in");
ofstream cout(PREFIX + ".out");
int t;
cin >> t;
while(t--) {
int x, y;
cin >> x >> y;
cout << get_gcd(x, y) << '\n';
}
}