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

O(1)方法公式的来源

Posted by jianingy at 2008-09-22 10:12:06 on Problem 1006
可以参考Wikipedia上线性同余同方程的解法,方法很简单手算一会就出来了。
http://en.wikipedia.org/wiki/Linear_congruence_theorem

也可以参考中国同余定理:http://en.wikipedia.org/wiki/Chinese_remainder_theorem

方程解出来是
x = 21252 * k - 504504 * p + 503217 * e + 1288 * i;

再简单利用余数的性质调整一下就能出:

x = (21252  + 5544 * p + 14421 * e + 1288 * i - d) % 21252;





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