Cod sursa(job #2336033)
| Utilizator | Data | 4 februarie 2019 18:46:41 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
long long power(int a, int b, int res){
if(b==0)
return 1;
if(b==1)
return a;
res=(1LL*power(a,b/2,res))%MOD;
if(b%2==0)
return (1LL*res*res)%MOD;
return (1LL*a*res*res)%MOD;
}
int main()
{
long long N, P, r = 1;
fin>>N>>P;
r=(1LL*power(N,P,1))%MOD;
fout<<r;
return 0;
}
