Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:计算((p^(eB+1)-1)/(p-1))%MODIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator