Pagini recente » Cod sursa (job #1163200) | Cod sursa (job #602023) | Cod sursa (job #1839633) | Cod sursa (job #2389767) | Cod sursa (job #1507567)
#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[i];
p1+=1<<k;
}
}
cout<<x;
}