Cod sursa(job #2858074)

Utilizator MR0L3eXMaracine Constantin Razvan MR0L3eX Data 26 februarie 2022 22:03:42
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"

using namespace std;

using ld = long double;
using ll = long long;
using ull = unsigned long long;

#if defined(ONPC)
#include "bits/debug.h"
#endif

ifstream fin("lgput.in");
ofstream fout("lgput.out");

const int MOD = 1999999973;

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

int binpow(int b, int e) {
    int res = 1;
    while (e) {
        if (e & 1) {
            res = mul(res, b);
        }
        b = mul(b, b);
        e /= 2;
    }
    return res;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, p;
    fin >> n >> p;
    
    fout << binpow(n, p) << "\n";
}