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:Re:我也在想这个问题 Posted by:sgzxy at 2008-06-14 16:03:30 > 不是吧……比如这组测试数据: > 9 > 15 3 2 11 4 1 8 8 8 > 答案是: > 第1 of 3根木棍: > 15+3+2=20 > 第2 of 3根木棍: > 11+8+1=20 > 第3 of 3根木棍: > 8+8+4=20 > 第1组测试数据结果:20 > > > 你按降序排了:15 11 8 8 8 4 3 2 1 > 那么从左往右搜索,会先找出15+4+1=20,这样后面的测试就会失败。 why do you select 4? Obviously 4 is not the one, which is added to get the just length of stick, i.e. 15 + 4 != 20. if 5 exists in the stick list, then 5 must be the best choice. prove: 1. if not exists a1...an, and a1+ a2 + ..+ an = 5, It is impossible to use other sticks to combine the length 20, except stick 5. 2. if exists a1...an, and a1 + a2 + .. + an = 5, in any place, 5 can be replaced by a1+a2+...+an, but the contrary is not correct. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator