快速幂

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mn=1e18;
ll pow(ll a,ll b,ll n){
	ll ans=1;
	ll base=a;
	while(b){
		if(b&1) ans=ans*base%n;
		base=base*base%n;
		b>>=1;
	}
	return ans;
}
int main(){
	ll x,y;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	while(cin>>x>>y){
		cout<<pow(x,y,mn)<<endl;
	}
	return 0;
}
posted @ 2018-08-23 14:17  ChunhaoMo  阅读(109)  评论(0编辑  收藏  举报