Cod sursa(job #2909863)

Utilizator _Fibonacci_Caitaz _Fibonacci_ Data 16 iunie 2022 12:28:24
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out"); 
long long x,y;
int t;

long long gcd(long long a,long long b)
{
    while (a>0 && b>0)
    {
        if (a>b) a=a%b;
        else b=b%a;
    }
    if (a>0) return a;
    else return b;
}

int main()
{
    fin >> t ;
    while (t--)
    {
        fin >> x >> y ;
        fout<< gcd(x,y)<<"\n";
    }
    return 0;
}