classSolution: defsuperPow(self, a: int, b: List[int]) -> int: MOD = 1337 ans = 1 for e inreversed(b): ans = ans * pow(a, e, MOD) % MOD a = pow(a, 10, MOD) return ans
intpow(int x, int n){ int res = 1; while (n) { if (n % 2) { res = (long) res * x % MOD; } x = (long) x * x % MOD; n /= 2; } return res; }
public: intsuperPow(int a, vector<int> &b){ int ans = 1; for (int i = b.size() - 1; i >= 0; --i) { ans = (long) ans * pow(a, b[i]) % MOD; a = pow(a, 10); } return ans; } };
publicintsuperPow(int a, int[] b) { intans=1; for (inti= b.length - 1; i >= 0; --i) { ans = (int) ((long) ans * pow(a, b[i]) % MOD); a = pow(a, 10); } return ans; }
publicintpow(int x, int n) { intres=1; while (n != 0) { if (n % 2 != 0) { res = (int) ((long) res * x % MOD); } x = (int) ((long) x * x % MOD); n /= 2; } return res; } }
publicintSuperPow(int a, int[] b) { int ans = 1; for (int i = b.Length - 1; i >= 0; --i) { ans = (int) ((long) ans * Pow(a, b[i]) % MOD); a = Pow(a, 10); } return ans; }
publicintPow(int x, int n) { int res = 1; while (n != 0) { if (n % 2 != 0) { res = (int) ((long) res * x % MOD); } x = (int) ((long) x * x % MOD); n /= 2; } return res; } }
var superPow = function(a, b) { let ans = BigInt(1); for (let i = b.length - 1; i >= 0; --i) { ans = ans * pow(BigInt(a), b[i]) % MOD; a = pow(BigInt(a), 10); } return ans; };
constpow = (x, n) => { let res = BigInt(1); while (n !== 0) { if (n % 2 !== 0) { res = res * BigInt(x) % MOD; } x = x * x % MOD; n = Math.floor(n / 2); } return res; }
classSolution: defsuperPow(self, a: int, b: List[int]) -> int: MOD = 1337 ans = 1 for e in b: ans = pow(ans, 10, MOD) * pow(a, e, MOD) % MOD return ans
publicintsuperPow(int a, int[] b) { intans=1; for (int e : b) { ans = (int) ((long) pow(ans, 10) * pow(a, e) % MOD); } return ans; }
publicintpow(int x, int n) { intres=1; while (n != 0) { if (n % 2 != 0) { res = (int) ((long) res * x % MOD); } x = (int) ((long) x * x % MOD); n /= 2; } return res; } }
publicintSuperPow(int a, int[] b) { int ans = 1; foreach (int e in b) { ans = (int) ((long) Pow(ans, 10) * Pow(a, e) % MOD); } return ans; }
publicintPow(int x, int n) { int res = 1; while (n != 0) { if (n % 2 != 0) { res = (int) ((long) res * x % MOD); } x = (int) ((long) x * x % MOD); n /= 2; } return res; } }
var superPow = function(a, b) { let ans = 1; for (const e of b) { ans = pow(BigInt(ans), 10) * pow(BigInt(a), e) % MOD; } return ans; };
constpow = (x, n) => { let res = BigInt(1); while (n !== 0) { if (n % 2 !== 0) { res = res * BigInt(x) % MOD; } x = x * x % MOD; n = Math.floor(n / 2); } return res; }