Cod sursa(job #756075)
| Utilizator | Data | 8 iunie 2012 22:54:03 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
long long cmmdc (long long a, long long b) {
long long c;
while (a) {
c = b % a;
b = a;
a = c;
}
return b;
}
int main () {
int t, a, b, c;
freopen ("euclid2.in", "rt", stdin);
freopen ("euclid2.out", "wt", stdout);
for (scanf ("%d", &t); t; -- t) {
scanf ("%d%d", &a, &b);
printf ("%d\n", cmmdc (a, b));
}
return 0;
}
