Cod sursa(job #146539)
Utilizator | Data | 1 martie 2008 21:11:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 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%2)
{
return (put(x,y-1)%m*x)%m;
}
else
{
return (put(x,y/2)%m)*(put(x,y/2)%m)%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;
}