Cod sursa(job #2574013)

Utilizator andreitudorpAndrei Tudor Popescu andreitudorp Data 5 martie 2020 19:58:05
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 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 & 1) ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        power >>= 1;
    }
    return ans;
}

int main() {

    int x, y;
    cin >> x >> y;W
    cout << pow(x, y);
    return 0;
}