Cod sursa(job #584290)
| Utilizator | Data | 24 aprilie 2011 21:21:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <cstdio>
using namespace std;
unsigned long long x,y,m;
long long put(long long x, long long y)
{
if(y==1) return x;
if(y&1)
return (put(x,(y-1)/2)*put(x,(y-1)/2)*x)%m;
else return (put(x,y/2)*put(x,y/2))%m;
}
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
m=1999999973;
scanf("%lld%lld",&x,&y);
printf("%lld\n",put(x,y));
return 0;
}
