my C++ Solution


  • 1
    S
    class Solution {
    const int DIV = 1337;
    public:
        int superPow(int a, vector<int>& b) 
        {
            int rem = a%DIV, rempow = 1;
            int result = 1;
            for(int i = b.size() - 1; i >= 0; i--)
            {
                int k = 0;
                while(k < 10)
                {
                    if(b[i] == k)
                        result = rempow*result%DIV;
    
                    k++;
                    rempow *= rem;
                    if(rempow >= DIV)
                        rempow %= DIV;
                }
                rem = rempow;
                rempow = 1;
            }
            return result%DIV;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.