Pagini recente » Cod sursa (job #359243) | Cod sursa (job #1846459) | Cod sursa (job #519217) | Cod sursa (job #2559091) | Cod sursa (job #1809718)
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
long long putere (long long a, long long b)
{
a = a % 1999999973;
if (b == 1)
{
return a;
}
if (b % 2 == 0)
{
long long n = b / 2;
a = a % 1999999973;
return putere(a * a, n);
}
else
{
return (putere (a, (b - 1) / 2) * a) % 1999999973;
}
}
int main()
{
// (a^b) % c = ?
// 1 <= a <= 2 * 10^9
// 1 <= b <= 2 * 10^19
// 2 <= c <= 666013
long long a, b, c = 1999999973;
fin >> a >> b;
a = a % c;
long long d = putere(a, b);
fout << d % c;
return 0;
}