题目如下:
Description
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.
Input
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.
Output
The output should contains the smallest possible length of original sticks, one per line.
Sample Input
9 5 2 1 5 2 1 5 2 1 4 1 2 3 4 0
Sample Output
6 5
题意很明显,一看就知道是用DFS的了,但是考察的是剪枝。第一次我没做剪枝就提交了,自然是TLE,后来 稍微加了一些判重居然就AC了,有点出人意料。听说有人居然做了9次剪枝才能过,Orz。下面贴一下代码:
ps:此程序过不了论坛上的bt测试数据。