Cod sursa(job #2618677)

Utilizator mex7Alexandru Valentin mex7 Data 25 mai 2020 18:31:48
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll mod = 1999999973;

ll power(ll base, ll pw) {
    if (pw == 1)
        return base;
    if (pw == 0)
        return pw;

    if (pw % 2)
        return base * power(base * base, pw / 2);
    return power(base * base, pw / 2);
}


int main() {
    int k, n;

    fin >> n >> k;

    fout << power(n, k) % mod;

    return 0;
}