Cod sursa(job #2027648)
Utilizator | Data | 26 septembrie 2017 15:04:16 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <cstdio>
#include <cstdlib>
typedef long long int LL;
LL gcd(LL a, LL b) {
while(b) {
long long aux = a;
a = b;
b = aux/a;
}
return a;
}
int main() {
freopen("euclid2.in", "r", stdin);
freopen("euclid2.out", "w", stdout);
int t;
scanf("%d", &t);
while(t--) {
LL a, b;
scanf("%lld%lld", &a, &b);
printf("%lld\n", gcd(a, b));
}
}