快速冪

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll qmul(ll a,ll b)
{
    ll ans=1,base=a;
    while(b)
    {
        if(b&1)ans*=base;
        base*=base;
        b>>=1;
    }
    return ans;
}


int main()
{
    ll a,b;
    while(1)
    {
        cin>>a>>b;
        cout<<qmul(a,b)<<endl;
    }
    return 0;
}

 

posted @ 2018-03-16 22:21  Sphreez  阅读(71)  评论(0编辑  收藏  举报