Cod sursa(job #1692080)
| Utilizator | Data | 20 aprilie 2016 00:46:09 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <fstream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
int cmmdc(int x, int y)
{
int r = x%y;
while (r)
{
x = y;
y = r;
r = x%y;
}
return y;
}
int t, a, b;
int main()
{
fin >> t;
while (t--)
{
fin >> a >> b;
fout << cmmdc(a, b) << '\n';
}
return 0;
}