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=”%dn”,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));
}
很詭異,而且不知是作者還是譯者有筆誤,已經造成我的腦袋打結了,算了,就不解了!