Cod sursa(job #2853555)

Utilizator Mike037Simion Mihnea Mike037 Data 20 februarie 2022 13:44:14
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.48 kb
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    freopen("euclid2.in","r",stdin);
    freopen("euclid2.out","w",stdout);

    int n;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        int a, b;

        cin >> a >> b;

        while(b != 0)
        {
            int aux = a % b;
            a = b;
            b = aux;
        }

        cout << a << "\n";
    }

    return 0;
}