Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Kuro-orzz/Library

:heavy_check_mark: NumberTheory/Aizu/aizu_alds1_1_b_gcd.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_B"

#include "../../template.h"

#include "../Math/Misc.h"


void solve() {
    ll a, b; cin >> a >> b;
    cout << GCD(a, b) << '\n';
}
#line 1 "NumberTheory/Aizu/aizu_alds1_1_b_gcd.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_B"

#line 2 "template.h"

#include <bits/stdc++.h>

using namespace std;
 
#define ll long long
#define MOD (ll)(1e9+7)
#define all(x) (x).begin(),(x).end()
#define unique(x) x.erase(unique(all(x)), x.end())
#define INF32 ((1ull<<31)-1)
#define INF64 ((1ull<<63)-1)
#define inf (ll)1e18

#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll get_rand(ll r) { return uniform_int_distribution<ll>(0, r - 1)(rng); }

const int mod = 998244353;

void solve();

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // cin.exceptions(cin.failbit);

    // int t; cin >> t;

    // while(t--)

        solve();
    cerr << "\nTime run: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << '\n';
    return 0;
}
#line 2 "NumberTheory/Math/Misc.h"


// for both negative + positive val

ll GCD(ll a, ll b) {
    a = llabs(a), b = llabs(b);
    return (!b ? a : GCD(b, a % b));
}
ll LCM(ll a, ll b) { return (!a || !b) ? 0 : llabs(a / GCD(a, b) * b); }

// Only positive

// ll GCD(ll a, ll b) { return (!b ? a : GCD(b, a % b)); }

// ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }


// logb(a)

double log_base(ll a, ll b) { return log(a) / log(b); }

// use for 2 <= BASE <= 36

string decimal_to_base(ll n, int BASE) {
    if (!n) return "0";
    bool neg = (n < 0 ? 1 : 0);
    n = llabs(n);
    string num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string res;
    while(n) {
        res.push_back(num[n % BASE]);
        n /= BASE;
    }
    if (neg) res += '-';
    reverse(all(res));
    return res;
}

// any BASE to decimal

// use ctype lib

ll convert_decimal(string s, int BASE) {
    auto val = [&](char c) { c = toupper(c); return (isdigit(c) ? c-'0' : c-'A'+10); };
    ll n = s.size(), p = 1, res = 0;
    for (int i = n-1; i >= 0; i--) {
        res += val(s[i]) * p;
        p = p * BASE;
    }
    return res;
}
#line 5 "NumberTheory/Aizu/aizu_alds1_1_b_gcd.test.cpp"

void solve() {
    ll a, b; cin >> a >> b;
    cout << GCD(a, b) << '\n';
}
Back to top page