Pagini recente » Cod sursa (job #1550377) | Cod sursa (job #2896825) | Cod sursa (job #1234135) | Cod sursa (job #1945168) | Cod sursa (job #2150509)
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
tuple<int, int, int> read_input() {
ifstream fin("lgput.in");
int base, exponent, mod = 0xDEADBEEF;
fin >> base >> exponent;
fin.close();
return make_tuple(base, exponent, mod);
}
int fast_pow(int base, int exponent, int mod) {
if (exponent == 1)
return base % mod;
if (exponent % 2 == 0)
{
int call_result = (1LL * fast_pow(base, exponent / 2, mod) % mod) % mod;
return (1LL * ((1LL * call_result) % mod) * call_result) % mod;
}
else
{
int result;
int call_result = (1LL * fast_pow(base, exponent / 2, mod) % mod) % mod;
result = base;
result = (1LL * result * call_result) % mod;
result = (1LL * result * call_result) % mod;
return result;
}
}
void print_output(int result) {
ofstream fout("lgput.out");
fout << result;
fout.close();
}
int main() {
int base, exponent, mod;
tie(base, exponent, mod) = read_input();
print_output(fast_pow(base, exponent, 1999999973));
// cout << fast_pow(575848, 1818888, 1000000007);
return 0;
}