Cod sursa(job #1969735)
Utilizator | Data | 18 aprilie 2017 17:04:51 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("euclid2.in");
ofstream fout ("euclid2.out");
int Gcd(int a, int b) {
while (b) {
int r = a % b;
a = b;
b = r;
}
return a;
}
int main() {
ios_base :: sync_with_stdio (false);
int t, a, b;
fin >> t;
while (t--) {
fin >> a >> b;
fout << Gcd(a, b) << "\n";
}
return 0;
}