Pagini recente » Cod sursa (job #21469) | Cod sursa (job #1898856) | Cod sursa (job #2785161) | Cod sursa (job #2018626) | Cod sursa (job #3164987)
#include <fstream>
using namespace std;
ifstream f("euclid2.in");
ofstream g("euclid2.out");
static inline int gcd(const int &a, const int &b)
{
if (!a)
return b;
if (!b)
return 0;
if (a > b)
return gcd((a % b), b);
return gcd(a, (b % a));
}
static inline void test_case()
{
int a = 0, b = 0;
f >> a >> b;
g << gcd(a, b) << '\n';
return;
}
int main()
{
f.tie(nullptr);
int t = 0;
f >> t;
for (int q = 1; q <= t; ++q)
test_case();
return 0;
}