Cod sursa(job #2649389)

Utilizator Rares31100Popa Rares Rares31100 Data 14 septembrie 2020 16:51:43
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>
#define UI unsigned int

using namespace std;

ifstream in("euclid2.in");
ofstream out("euclid2.out");
UI t, a, b;

UI cmmdc(UI a, UI b)
{
    UI rest;

    while(b)
    {
        rest = a % b;
        a = b;
        b = rest;
    }

    return a;
}

int main()
{
    in >> t;

    while(t--)
    {
        in >> a >> b;
        out << cmmdc(a, b) << '\n';
    }

    return 0;
}