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:RE~~ 很好的思路 :)

Posted by oyyvsbee at 2009-04-28 21:49:04 on Problem 1032
In Reply To:RE~~ 很好的思路 :) Posted by:wesleyme at 2006-03-02 01:35:55
> 做法就是求出以2起始的最大连续自然数序列之和sum,使得sum的值不超过输入数n,
> 然后分情况讨论:
> 
> 设此最大序列为2、3、……、i,则:
> 
> 1。若剩余值(n-sum)等于i,则最后输出序列为:3、4、……、i、i+2,即将原最大序列每项加1,再将最后剩余的一个1加到最后一项上。
> 
> 2。若剩余值(n-sum)小于i,则从序列的最大项i开始,从大到小依次将每项加1,直到剩余值用完。
> 
> 前面帖子里论述的几点规律可以证明这种做法的正确性。

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