372. Super Pow

来源:互联网 发布:商务调查软件 编辑:程序博客网 时间:2024/05/16 05:09
class Solution {private:    int base=1337;    int mypow(int a,int k)    {        a%=base;        int ret=1;        for(int i=0;i<k;i++)        {            ret=(ret*a)%base;        }        return ret;    }public:    int superPow(int a, vector<int>& b) {        if(b.size()==0)            return 1;        int lastdigit=b.back();        b.pop_back();        return mypow(superPow(a,b),10)*mypow(a,lastdigit)%base;    }};
1 0
原创粉丝点击