Cod sursa(job #2864783)
Utilizator | Data | 8 martie 2022 11:06:05 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
using namespace std;
#pragma GCC optimize ("Ofast")
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int x, y, n;
int euclid(int a, int b)
{
if(b == 0)
return a;
return euclid(b, a % b);
}
int main()
{
ios_base::sync_with_stdio(false);
fin >> n;
while(n--)
{
int x, y;
fin >> x >> y;
if(x < y)
swap(x, y);
fout << euclid(x, y) << '\n';
}
return 0;
}