0%

### leetcode Super Pow

Your task is to calculate $$a^b$$ mod 1337​ where a is a positive integer and b is an extremely large positive integer given in the form of an array.

Example1:

Example2:

$b^{e}=b^{\left(\sum _{i=0}^{n-1}a_{i}2^{i}\right)}=\prod _{i=0}^{n-1}\left(b^{2^{i}}\right)^{a_{i}}$

$c\equiv \prod _{i=0}^{n-1}\left(b^{2^{i}}\right)^{a_{i}}\ ({\mbox{mod}}\ m)$

c mod m = (a ⋅ b) mod m  = [(a mod m) ⋅ (b mod m)] mod m

C++

Java