Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

注意快速幂取模溢出

Posted by CROSShh at 2016-05-04 20:17:40 on Problem 1845
inline LL Mul_Mod(LL a, LL b , LL Mod)
{
	LL ans = 0 ;
	b %= Mod ;
	while (b) {
		if (b&1) ans = (ans + a ) % Mod ;
		b = b >> 1 ;
		a = a << 1 ;
		a %= Mod ;
	}
	return ans ;
}
inline LL Quick_Mod(LL a,int k,LL Mod)
{
	LL ans = 1 ;
	a %= Mod ;
	while (k) {
		if (k&1) ans = Mul_Mod(ans,a,Mod) ;
		k = k >> 1 ;
		a = Mul_Mod(a,a,Mod) ;
	}
	return ans ;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator