Pagini recente » Cod sursa (job #732991) | Cod sursa (job #357352) | Cod sursa (job #320265) | Borderou de evaluare (job #1832752) | Cod sursa (job #706673)
Cod sursa(job #706673)
#include <cstdio>
#define MAX 1999999973
int main()
{
freopen("lgput.in","rt",stdin);
freopen("lgput.out","wt",stdout);
long long n,a,y=1,x,k,step;
scanf("%I64d %I64d",&a,&n);
while(n)
{
x=a;
for(step=1,k=0;step<=n;step<<=1,k++);
k--;
step>>=1;
for(long i=1;i<=k;i++)
x*=x,x%=MAX;
n-=step;
y*=x,y%=MAX;
}
printf("%I64d\n",y);
}