Cod sursa(job #472128)
| Utilizator | Data | 22 iulie 2010 23:43:00 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <cstdio>
using namespace std;
#define FIN "euclid2.in"
#define FOUT "euclid2.out"
long long gcd(long long a, long long b) {
while (a && b) {
a %= b;
if (a) {
b %= a;
}
}
return a + b;
}
int main(void) {
int tests;
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
scanf("%d", &tests);
while (tests--) {
int a, b;
scanf("%d%d", &a, &b);
printf("%lld\n", gcd(a, b));
}
return 0;
}
