// https://discuss.leetcode.com/topic/50489/c-clean-and-short-solution class Solution {
int base = ;
int powMod(int a, int b) {
a %= base;
int result = ;
for (int i=; i<b; i++) {
result *= a;
result %= base;
}
return result;
} public:
int superPow(int a, vector<int>& b) {
if (b.empty()) {
return ;
}
int t = b.back();
b.pop_back(); return (powMod(superPow(a, b), ) * powMod(a, t)) % base; }
};