Cod sursa(job #739612)
| Utilizator | Data | 23 aprilie 2012 16:12:34 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <cstdio>
#define MOD 199999973
long long cb(long long x,long long y){
if(y==0) return 0;
if(y==1) return x%MOD;
if(y%2==0)return (cb(x,y/2)*cb(x,y/2))%MOD;
if(y%2!=0) return (cb(x,y-1)*cb(x,1))%MOD;
}
int main (){
long long x,y;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld", &x);
scanf("%lld", &y);
printf("%lld", cb(x,y));
}