similiar to quick_pow


  • 0
    G

    the solution is similiar to quick_pow(if you dont know what is quick_pow,pls search)
    here is the code
    ...
    int superPow(int a, vector<int>& b) {
    int j=b.size()-1;
    int ans=1,p=1337;
    a=a%p;
    while(j>=0)
    {
    int c=a;
    while(b[j]>0)
    {
    if(b[j]&1==1)
    {
    ans=ansc;
    ans=ans%p;
    }
    b[j]=b[j]>>1;
    c=c
    c;
    c=c%p;
    }
    int mu=1,d=10;
    while(d>0)
    {
    if(d&1==1)
    {
    mu=mua;
    mu=mu%p;
    }
    d=d>>1;
    a=a
    a;
    a=a%p;
    }
    a=mu;
    j--;
    }
    return ans;
    }
    };
    ...


Log in to reply
 

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