Cod sursa(job #3256017)

Utilizator rjytyjtjtjwee woo rjytyjtjtj Data 12 noiembrie 2024 22:54:08
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <iostream>

#define MOD 1999999973
#define ll long long
using namespace std;

ll power(ll a, ll b, ll mod) {
    if (b == 0)
        return 1;
    if (b % 2 == 1)
        return (a * power(a, b - 1, mod)) % mod;

    ll x = power(a, b / 2, mod);
    return (x * x) % mod;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = power(a, b, MOD);
    cout << ans << '\n';
}