PKU1011解題ing

要開始做PKU1011題了,先翻譯一下:

PKU1011
Sticks
木棍
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.
輸入包含兩行,第一行是切斷後的小木棍的總數,至多是64;第二行是小木棍的長度,用空格分開;最後一行是0,代表程序退出。

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

我把它改成了一個數學題,是這樣描述的:
假設有m個正整數X1,X2,X3,...Xm, 求一個正整數R,滿足以下條件:
1)(X1+X2+X3+...+Xm)%R=0;也就是說總和可能整除R;
2)R>=X1,X2,X3,...Xm;R大於等於m個正整數裏的任何一個;
3)恰巧能將這m個數據分成(X1+X2+X3+...+Xm)/R組,設共有t組,每一組的和爲R;
4)R是滿足以上三個條件的最小值;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章