Cod sursa(job #584277)
| Utilizator | Data | 24 aprilie 2011 21:01:53 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| 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%2)
{
return (put(x,y-1)*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;
}