Pagini recente » Cod sursa (job #2771555) | Cod sursa (job #186604) | Cod sursa (job #406193) | Cod sursa (job #2409341) | Cod sursa (job #3236073)
#include <stdio.h>
#define M 1999999973
long long exp_log(long long y, long long x, int n)
{
if (!n)
{
return y;
}
if (n & 1)
{
return exp_log((y * x) % M, (x * x) % M, (n - 1) / 2);
}
else
{
return exp_log(y % M, (x * x) % M, n / 2);
}
}
int main()
{
FILE *filein = fopen("lgput.in", "rb");
FILE *fileout = fopen("lgput.out", "wb");
long long n, p;
fscanf(filein, "%lld", &n);
fscanf(filein, "%lld", &p);
fclose(filein);
fprintf(fileout, "%lld\n", exp_log(1, n, p));
fclose(fileout);
return 0;
}