Cod sursa(job #2573982)

Utilizator andreitudorpAndrei Tudor Popescu andreitudorp Data 5 martie 2020 19:49:45
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>

using namespace std;

ifstream cin("lgput.in");
ofstream cout("lgput.out");

#define MOD 1999999973

typedef long long ll;

ll pow(ll base, ll power) {
    ll ans = 1;
    while(power > 0) {

        if(power % 2 == 1)
            ans = (ans * base) % MOD;

        base = (base * base) % MOD;

        power = power / 2;
    }
    return ans;
}

int main() {

    int x, y;
    cin >> x >> y;

    cout << pow(x, y);
    return 0;
}