Cod sursa(job #1009817)
Utilizator | Data | 13 octombrie 2013 21:25:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <stdio.h>
#define P 1999999973
#define ll long long
ll raisetopower(ll a,ll b){
if(b==1)return a;
ll r=raisetopower(a,b/2)%P;
r=(r*r)%P;
return ((b%2)?a*r:r)%P;
}
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
ll a,b;
scanf("%lld%lld",&a,&b);
printf("%lld\n",raisetopower(a,b));
return 0;
}