Cod sursa(job #3350079)

Utilizator eric_dragosDragos Eric eric_dragos Data 5 aprilie 2026 11:47:53
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define MOD 1999999973
ll fastexp(int base, int exp){
    ll t = 1LL;
    while(exp > 0){
        if(exp % 2 == 1) t = (t*base)%MOD;

        base = (base*base)%MOD;
        exp/=2;
    }

    return t % MOD;
}

int main(){
    ll n,p;
    fin >> n >> p;
    fout << fastexp(n, p) % MOD ;
    return 0;
}