快速幂&矩阵快速幂

int quickpow(int x,int n,int p){   //o(logn)  //x的n次方mod p
	int res=1;
	while(n){
		if(n&1) res=res*x%p;
		x=x*x%p;	
		n=n>>1;
	}
	return res;
}

 

posted @ 2023-11-22 22:46  osir  阅读(0)  评论(0编辑  收藏  举报