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:用笨办法太慢了,高手能指点指点吗?

Posted by fly_away at 2006-08-17 12:03:52 on Problem 2853
In Reply To:用笨办法太慢了,高手能指点指点吗? Posted by:Jaaason at 2006-07-17 15:09:53
假设连续的数第一个为i,共有j个数,则(2 * i + j - 1) * j = 2 * n
只需求出这个不定方程的解数即可。显然2 * i + j - 1 > j,于是j < sqrt(2 * n),
方程有解的条件是(2 * n % j == 0) && (j + 2 * n / j) % 2 != 0 有多少个j满足条件就有多少个解,编程实现就很简单了

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