Pagini recente » Cod sursa (job #28425) | Cod sursa (job #2020053) | Cod sursa (job #1428314) | Cod sursa (job #1471591) | Cod sursa (job #1507564)
#include <iostream>
#include <cstdio>
using namespace std;
int x,p1,p,V[100000],k,i;
int main()
{
// std::ios::sync_with_stdio(false);
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
cin>>x>>p;
V[1]=x;
V[0]=1;
p1=1;
while (p>=(p1<<1))
{
x=x*x;
p1<<=1;
k++;
V[k]=x;
}
for (i=k;i>=0&&p1<p;i--)
{
if ((p1+1<<k)<p)
{
x*=V[k];
p1+=1<<k;
}
}
cout<<x;
}