Cod sursa(job #3005514)
Utilizator | Data | 17 martie 2023 08:04:10 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
int gcd(int a, int b)
{
int r;
while (b)
{
int r = a % b;
a = b;
b = r;
}
return a;
}
int main()
{
ifstream fin("abx.in");
ofstream fout("abx.out");
int n, x, y;
fin >> n;
while (n--)
{
fin >> x >> y;
fout << gcd(x, y);
}
return 0;
}