Cod sursa(job #2886622)
| Utilizator | Data | 7 aprilie 2022 22:59:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const ll mod=1999999973;
ll powerLOG(ll a, ll b){
if(b==0)
return 1;
if(b%2==0){
a=(a*a)%mod;
b=b/2;
return powerLOG(a,b)%mod;
}
return (a*powerLOG(a,b-1))%mod;
}
int main()
{
ll N, P;
fin>>N>>P;
fout<<powerLOG(N,P);
fin.close();
fout.close();
return 0;
}
