Cod sursa(job #2928889)

Utilizator Apyxabcdefghij Apyx Data 24 octombrie 2022 01:54:50
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include <bits/stdc++.h>

using namespace std;

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

const long long abc = 1999999973;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while(b > 0) {
        if(b & 1) {
            res = res * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    fin.tie(0);
    fout.tie(0);
    int a, b; fin >> a >> b;
    fout << binpow(a, b, abc);
    return 0;
}