Cod sursa(job #728365)
Utilizator | Data | 28 martie 2012 17:59:15 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
/* http://infoarena.ro/problema/euclid2 */
#include <fstream>
using std::ifstream;
using std::ofstream;
int main() {
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int n, a, b, r;
in >> n;
while(n) {
--n;
in >> a >> b;
do {
r = a % b;
a = b;
b = r;
} while(r != 0);
out << a << '\n';
}
}