Cod sursa(job #1044118)
| Utilizator | Data | 29 noiembrie 2013 12:38:45 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include<stdio.h>
#define MOD 1999999973
long long pow(int N,int P){
long long temp;
if(P==0)
return 1;
else{
temp = pow(N,P/2);
if(!(P&1))
return ((temp*temp)%MOD);
else
return (((temp*temp)%MOD)*N)%MOD;
}
}
int main(){
int N,P;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d",&N,&P);
printf("%lld",(long long)pow(N,P));
return 0;
}
