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

Re:计算((p^(eB+1)-1)/(p-1))%MOD

Posted by mxd543 at 2009-09-16 21:58:04 on Problem 1845
In Reply To:计算((p^(eB+1)-1)/(p-1))%MOD Posted by:dirtysalt at 2009-09-04 15:32:53
> 1.可以首先计算rem=p^(eB+1)%(MOD*(p-1))
> 2.然后计算rem=(rem-1+MOD*(p-1))/(p-1)
> 3.最后计算rem%MOD
> 这样不需要二分。但是MOD*(p-1)可能会超过32位,所以在计算p^(eB+1)%(MOD*(p-1))时候可能乘法会溢出....careful....

我感觉(rem-1+MOD*(p-1))%(p-1)不一定为0.

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