Pagini recente » Teorema chineza a resturilor - generalizari si aplicatii | Cod sursa (job #2739329) | Cod sursa (job #1986341) | Cod sursa (job #397855) | Cod sursa (job #1337436)
#include <fstream>
using namespace std;
#define MOD 1999999973LL
long long n, p, x,y;
ifstream f("lgput.in");
ofstream g("lgput.out");
void compute()
{
x = n;
y = 1;
while (p > 1)
{
if (p % 2 == 1)
{
y = y*x % MOD;
x = x*x % MOD;
p = (p - 1) / 2;
}
else
{
x = x*x % MOD;
p /= 2;
}
}
g << ( (y * x) % MOD );
}
int main()
{
f >> n >> p;
compute();
f.close();
g.close();
}