Cod sursa(job #3123512)

Utilizator vladorovOroviceanu Vlad vladorov Data 24 aprilie 2023 11:11:31
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <iostream>
#include <fstream>

using namespace std;

typedef long long i64;

i64 pow(i64 baza, i64 exp){
    if(exp==0) return 1;

    i64 result=pow(baza, exp/2);

    if(exp%2==0) return result*result;

    return result*result*baza;
}

#define NR 1999999973

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

    int N, P;
    fin>>N>>P;

    fout<<pow(N, P)%NR;

    return 0;
}