Pagini recente » Cod sursa (job #687609) | Cod sursa (job #1690522) | Cod sursa (job #2707999) | Borderou de evaluare (job #1509968) | Cod sursa (job #1239923)
#include <cstdio>
using namespace std;
unsigned long long p2;
int x,a,i,p,j,b[1001];
int main ()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d%d", &a, &p);
i=0;
while(p>0)
{
++i;
b[i]=p%2;
p=p/2;
}
x=1999999973;
p2=1;
for(j=i;j>=1;--j)
{
if(b[j]==1)
p2=(((p2*p2)%x)*a)%x;
else
p2=(p2*p2)%x;
}
printf("%lld", p2%x);
return 0;
}