Cod sursa(job #261459)
Utilizator | Data | 18 februarie 2009 12:20:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <stdio.h>
long long power(long long nn,long long pp)
{
long long t;
if (!pp) return 1;
else
if (pp%2==0){
t=power(nn,pp/2);
return (t*t)%1999999973;
}
else return (nn*power(nn,pp-1))%1999999973;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long n,p;
scanf("%lld%lld",&n,&p);
printf("%lld\n",power(n,p));
}