Cod sursa(job #1127298)
Utilizator | Data | 27 februarie 2014 11:55:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
/*
Keep It Simple!
*/
#include<stdio.h>
#define mod 1999999973
long long N,P,pow;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&N,&P);
pow = 1;
while(P)
{
if( P%2 )
{
pow = (pow*N)%mod;
P--;
}
N = (N*N) % mod;
P/=2;
}
printf("%lld",pow);
}