Cod sursa(job #2029101)

Utilizator MaligMamaliga cu smantana Malig Data 29 septembrie 2017 11:57:32
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");

const int NMax = 1e3 + 5;
const int inf = 1e9 + 5;
const int mod = 1999999973;
using zint = short;

ll N,P;

ll pw(ll,ll);

int main() {
    in>>N>>P;
    out<<pw(N,P)<<'\n';

    in.close();out.close();
    return 0;
}

ll pw(ll base,ll exp) {
    ll ans = 1;
    while (exp) {
        if (exp & 1) {
            ans = (ans * base) % mod;
        }
        base = (base * base) % mod;
        exp >>= 1;
    }

    return ans;
}