高速べき乗取りアルゴリズムテンプレート-x^y%mode=?


考え方は非常に簡潔なアルゴリズムであり、ここではアルゴリズムテンプレートのみを提示しています.読者が読む前に、素早くべきアルゴリズムを詳しく知ることを勧めています.
//    
//         
#include 
#define LL long long
using namespace std;
LL Fast_power(LL x,LL y,LL mode)
{
	LL sum=1;
	while(y)
	{
		if(y&1)sum=((sum%mode)*(x%mode))%mode; //      
		x=(x%mode)*(x%mode);
		y=y>>1;
	}
	return sum;
}
int main()
{
	int a,b,mode;cin>>a>>b>>mode;
	cout<