Pagini recente » Cod sursa (job #744239) | Cod sursa (job #784191) | Diferente pentru problema/pixels intre reviziile 5 si 4 | Borderou de evaluare (job #1524054) | Cod sursa (job #1752600)
#include <fstream>
#include <cmath>
#define MOD 1999999973
using namespace std;
long long rest(long long N, long long P)
{
long long a;
if(P==1)
{
return N;
}
if(P%2==0)
{
a=rest(N,P/2);
a=(a*a)%MOD;
return a;
}
else
{
a=rest(N,(P-1)/2);
a=(a*a*N)%MOD;
return a;
}
}
int main()
{
long long N,P;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld %lld",&N,&P);
printf("%lld",rest(N,P));
}