Cod sursa(job #1100584)
| Utilizator | Data | 7 februarie 2014 00:41:32 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include<cstdio>
using namespace std;
typedef long long int LL;
const int MOD = 1999999973;
LL N,P;
inline LL Exp(LL B,LL E)
{
if(E==0) return 1LL;
if(E==1) return B;
LL t=Exp(B,E/2);
return ((t*t)%MOD*Exp(B,E%2))%MOD;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&N,&P);
N%=MOD;
printf("%lld\n",Exp(N,P));
return 0;
}
