acwing 167. stick

George brought sticks of equal length, they are cut off at random, the length of each section such that the stick is not more than 50 units of length.

Then he wants to return to these sticks is cut before the cut-off state, but can not remember how many there are initial length of the stick, and the stick initially.

Please design a program that might help calculate the minimum length of George's stick.

The length of an integer with each section are greater than zero stick representation.

Note: the stick may contain data length greater than 50, please ignore these stick during processing.

Input Format

Input data comprises a plurality of sets, each set includes two rows of data.

The first line is an integer of not more than 64, showing the section cut off after a total of how many sticks.

The second line is the length of the sections cut off after the stick, the resultant.

After the last set of data is a zero.

Output Format

For each set of data and outputs the original wooden smallest possible length, each set of data per line.

Sample input:

9
5 2 1 5 2 1 5 2 1
4
1 2 3 4
0

Sample output:

6
5

Guess you like

Origin www.cnblogs.com/itdef/p/10945328.html