Cod sursa(job #875248)
Utilizator | Data | 9 februarie 2013 20:44:10 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
static inline unsigned gcd(unsigned x, unsigned y)
{
if(!y) return x;
return gcd(y, x%y);
}
int main()
{
ifstream in("euclid2.in");
ofstream out("euclid2.out");
int n;
in >> n;
unsigned x, y;
for(int i = 0; i < n; ++i)
{
in >> x >> y;
out << gcd(x, y) << endl;
}
return 0;
}