// https://discuss.leetcode.com/topic/50489/c-clean-and-short-solution

class Solution {
    int base = 1337;
    int powMod(int a, int b) {
        a %= base;
        int result = 1;
        for (int i=0; i<b; i++) {
            result *= a;
            result %= base;
        }
        return result;
    }
    
public:
    int superPow(int a, vector<int>& b) {
        if (b.empty()) {
            return 1;
        }
        int t = b.back();
        b.pop_back();
        
        return (powMod(superPow(a, b), 10) * powMod(a, t)) % base;
        
    }
};

 

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-06-14
  • 2021-04-20
  • 2021-10-11
  • 2022-12-23
  • 2021-11-29
  • 2021-11-24
猜你喜欢
  • 2022-02-15
  • 2021-07-18
  • 2021-11-27
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
相关资源
相似解决方案