POJ.1011 Sticks

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 44151 Accepted: 9856

Description

给出N根小木棒(以下称小棒)的长度Li,已知这N根小木棒原本由若干根长度相同的长木棒(以下称原棒)分解而来。要求出原棒的最小可能长度。

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

Short Coding写出简捷好程式-短码达人的心得技法的p.253的最后程式码,我已经看不出来哪里错了?

L,F,*I;

c(n,t,p,j)
{
–I[p];
for(j=t-=p;F*j;–j)I[j]&&c(n,t,j);
for(j=F=–n?F:0;!I[j];)–j;
t||c(n,L,j);
++I[p];
}

main(s,b)
{
int w[999]={s=0};

for(scanf(b=”%d\n”,I=w);~–*w;s+=F<L?F=L:L)
scanf(b,&L),++w[L];

for(L=F-1;F;)
s&++L||c(s/L,L,F);

s&&main(printf(b,L));
}

很诡异,而且不知是作者还是译者有笔误,已经造成我的脑袋打结了,算了,就不解了!