快速幂模板

快速幂模板

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define maxn 500050
#define INF 0x3f3f3f
using namespace std;

typedef long long ll;
const int mod = 9901;

int a, b;

int main()
{
    while(cin >> a >> b)
    {
        int ans = 1 % mod;
        while(b)
        {
            if(b & 1)
                ans = ans % mod * a % mod;
            a = a % mod * a % mod;
            b >>= 1;
        }
        cout << ans << endl;
    }
    return 0;
}

你可能感兴趣的:(模板)