您的位置:首页 > 其它

PKU1011解题ing

2010-06-21 15:11 791 查看
要开始做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是满足以上三个条件的最小值;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: