Cod sursa(job #2468827)
Utilizator | Data | 5 octombrie 2019 23:57:57 | |
---|---|---|---|
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;
int t, a, b;
int gcd(int a, int b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
int main()
{
freopen("euclid2.in", "r", stdin);
freopen("euclid2.out", "w", stdout);
scanf("%d", &t);
while (t--) {
scanf("%d %d", &a, &b);
printf("%d\n", gcd(a, b));
}
return 0;
}