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是满足以上三个条件的最小值;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值