easy C++ soluton


  • 0
    Y
    class Solution {
    public:
        int superPow(int a, vector<int>& b) {
            long long p = 1;
            if(a < 1)
                return -1;
            if(a == 1)
                return 1;
            
            for(int i = 0; i < b.size(); i ++)
            {
                long long t = p;
                p = 1;
                for(int k = 0; k < 10; k ++)
                    p = (p * t) % 1337;
                
                for(int k = 0; k < b[i]; k ++)
                    p = (p * a) % 1337;    
            }
            
            return p % 1337;
            
        }
    };
    

Log in to reply
 

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