Cod sursa(job #2881013)

Utilizator QwertyDvorakQwerty Dvorak QwertyDvorak Data 30 martie 2022 11:05:29
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define dbg(x) cout << #x <<": " << x << "\n";
#define sz(x) ((int)x.size())

using ll = long long;

const string fn = "euclid2";
ifstream fin(fn + ".in");
ofstream fout(fn + ".out");

int t;

int gcd(int a, int b){
    while(b!=0){
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){

    fin >> t;
    while(t--){
        int a, b;
        fin >> a >> b;
        fout << gcd(a, b) << '\n';
    }

    return 0;
}