Pagini recente » Cod sursa (job #2647543) | Cod sursa (job #1130991) | Cod sursa (job #1170374) | Cod sursa (job #937060) | Cod sursa (job #2030222)
#include <iostream>
#define N 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p;
long long ridicare(long long x, long long z)
{
if (z == 0)
return 1;
if(z == 1)
return n%N;
int y = 1;
while (z > 1) {
if (z % 2 == 0)
{
x = (x * x) % N;
z = z / 2;
}
else
{
y = (y * x) % N;
x = (x * x) % N;
z = (z - 1) / 2;
}
}
return (x * y) % N;
}
int main()
{
fin>>n>>p;
fout<<ridicare(n,p);
return 0;
}