Cod sursa(job #1799152)
Utilizator | Data | 5 noiembrie 2016 20:46:00 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
int gcd(const int a, const int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int tests;
in >> tests;
for (; tests > 0; --tests) {
int a, b;
in >> a >> b;
out << gcd(a, b) << "\n";
}
return 0;
}