Cod sursa(job #2663859)

Utilizator cyg_dawidDavid Ghiberdic cyg_dawid Data 27 octombrie 2020 15:11:59
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>

using namespace std;
typedef long long ll;

ifstream fin("euclid2.in");
ofstream fout("euclid2.out");

ll t;
ll a, b;

ll gcd() {
    ll r;
    while(b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    fin.tie(0);
    fout.tie(0);

    fin >> t;
    while(t--) {
        fin >> a >> b;
        fout << gcd() << "\n";
    }
    return 0;
}