Cod sursa(job #3125197)
Utilizator | Data | 2 mai 2023 11:21:32 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f ("euclid2.in");
ofstream g ("euclid2.out");
int x, y, t;
int solve(int &x, int &y)
{
while (y)
{
int r = x % y;
x = y;
y = r;
}
return x;
}
int main()
{
f >> t;
while (t--)
{
f >> x >> y;
g << solve(x, y) << '\n';
}
return 0;
}