int superPow(int a, vector<int>& b) { if(b.empty()) return 1; a = a%1337; int lastBit = b.back(); b.pop_back(); return (superPow(superPow(a, b), 10) * superPow(a, lastBit))%1337; }
int superPow(int a, vector<int>& b) { if(all_same(b, 0)) return 1; if(all_same(b, 1)) return a%MOD; bool odd_flag = (b.back()&1 != 0); reduceby2(b); if(odd_flag) return (a%MOD * superPow(((a%MOD) * (a%MOD))%MOD, b))%MOD; else return superPow(((a%MOD) * (a%MOD))%MOD, b)%MOD; }
int superPow(int a, vector<int>& b) { if(b.empty()) return 1; int m = b.back(); b.pop_back(); return powMod(superPow(a, b), 10) * powMod(a, m) % base; }
int superPow(int a, vector<int>& b) { if(b.empty()) { return 1; } int bak = b.back(); b.pop_back(); return powMode(superPow(a, b), 10)*powMode(a, bak)%1337; }