Cod sursa(job #3033063)
Utilizator | Data | 23 martie 2023 11:59:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.54 kb |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll n, p;
const ll mod=1999999973;
ll er(const ll b, const ll e)
{
if(e==0) return 1;
if(e&1) return b*er(b, e-1)%mod;
const ll p=er(b, e/2)%mod;
return p*p%mod;
}
ll pow(const ll b, const ll e)
{
if(b==0) return 0;
if(b==1) return 1;
if(e==0) return 1;
if(e==1) return b%mod;
return er(b%mod, e);
}
int main()
{
fin>>n>>p;
fout<<pow(n, p)<<endl;
return 0;
}