Pagini recente » Cod sursa (job #2663304) | Cod sursa (job #1634132) | Cod sursa (job #297001) | Cod sursa (job #648335) | Cod sursa (job #2234083)
#include <iostream>
#include <fstream>
#include <vector>
const int mod = 1999999973;
using namespace std;
class Task {
public:
void solve() {
read_input();
print_output(fast_pow(base, exponent, mod));
}
private:
long long base, exponent;
void read_input() {
ifstream fin("lgput.in");
fin >> base >> exponent;
fin.close();
}
long long fast_pow(long long base, long long exponent, int mod) {
if(exponent < 0) return fast_pow(1 / base, -exponent, mod);
else if(exponent == 0) return 1;
else if(exponent == 1) return base;
else if(exponent % 2 == 0) return fast_pow((base * base % mod), exponent / 2, mod) % mod;
else if(exponent % 2 != 0) return base * fast_pow(base * base % mod, (exponent - 1) / 2, mod) % mod;
return 0;
}
void print_output(long long result) {
ofstream fout("lgput.out");
fout << result;
fout.close();
}
};
int main() {
Task task;
task.solve();
return 0;
}