George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long they were originally. Please help him and design a program which computes the smallest possible original length of those sticks. All lengths expressed in units are integers greater than zero.
The input contains blocks of 2 lines. The first line contains the number of sticks parts after cutting, there are at most 64 sticks. The second line contains the lengths of those parts separated by the space. The last line of the file contains zero.
The output should contains the smallest possible length of original sticks, one per line.

本文探讨了如何使用深度优先搜索(DFS)结合剪枝技术来解决复杂问题。作者分享了两种不同的实现方式,其中一种是个人原创,另一种是从网络上获取的灵感。在第二種方法中,特别提到了在求和为0的情况下的讨论对于避免超时至关重要。
最低0.47元/天 解锁文章
2664

被折叠的 条评论
为什么被折叠?



