Leetcode 372 Solution
This article provides solution to leetcode question 372 (super-pow)
Access this page by simply typing in "lcs 372" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/super-pow
Solution
class Solution {
public:
int pow(int a, int b)
{
if (b == 0)
return 1;
int64_t c = pow(a, b / 2);
if (b % 2 == 0)
return (c * c) % 1337;
else
return (c * c * a) % 1337;
}
int superPow(int a, vector<int>& b) {
int c = 1;
for (int i = 0; i < b.size(); i++)
c = (pow(c, 10) * pow(a, b[i])) % 1337;
return c;
}
};