Cod sursa(job #2206258)

Utilizator heisenbugAnnoying Heisenbug heisenbug Data 21 mai 2018 22:25:45
Problema Algoritmul lui Euclid Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include <fstream>

template <typename T>
T cmmdc(T a, T b)
{
    while (b != 0) {
        long r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    std::ifstream fin("euclid2.in");
    std::ofstream fout("euclid2.out");

    int t;
    fin >> t;

    while (t-- > 0) {
        long a, b;
        fin >> a >> b;
        fout << cmmdc(a, b) << '\n';
    }

    return 0;
}