Cod sursa(job #759151)
Utilizator | Data | 16 iunie 2012 22:14:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <cstdio>
#define M 1999999973
typedef long long ll;
ll n,k;
ll pow(ll n,ll k){
if(k==1)return n%M; else
if(k>1)
{
ll z=pow(n,k/2);
if(k%2) return z*z*n%M; else return z*z%M;
}
}
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld %lld",&n,&k);
printf("%lld\n",pow(n,k));
return 0;
}