Cod sursa(job #1493891)
Utilizator | Data | 30 septembrie 2015 00:12:55 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
#define ui unsigned int
using namespace std;
ui cmmdc(ui a, ui b) {
if (b == 0) {
return a;
}
return cmmdc(b, a % b);
}
int main() {
ifstream cin("euclid2.in");
ofstream cout("euclid2.out");
int n;
cin >> n;
for (int i = 0; i < n; ++i)
{
ui a, b;
cin >> a >> b;
cout << cmmdc(a, b) << '\n';
}
return 0;
}