Pagini recente » Cod sursa (job #1946542) | Cod sursa (job #2729303) | Cod sursa (job #163425) | Cod sursa (job #3227972) | Cod sursa (job #2234064)
#include <iostream>
#include <fstream>
#include <vector>
const long 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();
}
int fast_pow(long base, long exponent, long mod) {
if(exponent == 0) return 1;
else if(exponent == 1) return base % mod;
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(int result) {
ofstream fout("lgput.out");
fout << result;
fout.close();
}
};
int main() {
Task task;
task.solve();
return 0;
}