Pagini recente » Cod sursa (job #2165854) | Cod sursa (job #1377003) | Cod sursa (job #26430) | Cod sursa (job #1302680) | Cod sursa (job #2776929)
//
// Created by Andrei Covaci on 03.09.2021.
// https://infoarena.ro/problema/ciur
//
#include <fstream>
#include <iostream>
#include <vector>
#include <map>
//#define INPUT "permutari.in"
//#define OUTPUT "permutari.out"
#define INPUT "input.in"
#define OUTPUT "output.out"
using namespace std;
pair<long long, int> read() {
ifstream in(INPUT);
int a, b;
in >> a >> b;
in.close();
return pair<long long, int>(a, b);
}
long long solve(pair<int, int> p) {
long long a = p.first;
int b = p.second;
long long s = 1, exp = 0;
map<int, long long> cache;
cache[1] = a;
cache[2] = a * a;
cache[3] = a * a * a;
cache[4] = cache[2] * cache[2];
cache[5] = cache[2] * cache[3];
cache[6] = cache[3] * cache[3];
while(exp != b) {
int delta = b - exp;
pair<int, long long> curr;
for(auto e : cache) {
if (e.first > delta) {
break;
}
curr = e;
}
s *= curr.second;
exp += curr.first;
}
return s % 1999999973;
}
void print(int n) {
ofstream out(OUTPUT);
out << n;
out.close();
}
int main() {
auto nums = read();
auto res = solve(nums);
print(res);
return 0;
}