Cod sursa(job #3360404)

Utilizator NumberzAndStuffMihail Grecu NumberzAndStuff Data 13 iulie 2026 15:05:30
Problema Algoritmul lui Euclid Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.58 kb
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#pragma GCC target("popcnt")
#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define db long double

const ll INF = 1e18;
const ll MOD = 1e9+7;
const int lg = 31;
const ll inv2 = 500000004;
ll add(ll a, ll b, ll MD = MOD) {return (a+b)%MD;}
ll mns(ll a, ll b, ll MD = MOD) {return add((a-b)%MD, MD);}
ll mult(ll a, ll b, ll MD = MOD) {return ((a%MD) * (b%MD)) % MD;}

ll expo(ll a, ll e = MOD - 2, ll MD = MOD) {
    ll r = 1;
    while (e) {
        if (e & 1) r = mult(r, a, MD);
        a = mult(a, a, MD);
        e >>= 1;
    }
    return r;
}

//stolen
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() ^ random_device{}());

template<class T>
using OSET = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//-------------------------------------------------------------------------------------

ifstream ccin("euclid2.in");
ofstream ccout("euclid2.out");

ll gcd(ll a, ll b) {
    if (!b) return a;
    if (a < b) swap(a, b);
    return gcd(b, a%b);
}

void solve() {
{

    ll a, b;
    ccin >> a >> b;
    ccout << gcd(a, b) << '\n';

}}

int main() {
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(std::ios::fixed); cout.precision(17);

	int tt = 1;
    ccin >> tt;
    while (tt--) solve();

	return 0;
}}