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:用笨办法太慢了,高手能指点指点吗?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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator