Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我过了,太坎坷了!提供题解和代码:题解:http://hi.baidu.com/lydrainbowcat/blog/item/fbe8db6687c3b332aa184c65.html var f:array[0..30000]of boolean; d:array[0..30000]of longint; a:array[0..100]of longint; b:array[0..100]of double; sum:double; n,i,j:longint; procedure print(x:longint); begin if x=0 then exit; print(x-a[d[x]]); if x<>i then write(d[x],' ') else writeln(d[x]); end; begin repeat readln(n); if n=0 then exit; sum:=0; for i:=1 to n do begin readln(b[i]); sum:=sum+b[i]; end; for i:=1 to n do a[i]:=trunc((b[i]/sum)*20000); fillchar(f,sizeof(f),0); f[0]:=true; for i:=1 to n do for j:=10000 downto 0 do if f[j] and not f[j+a[i]] then begin f[j+a[i]]:=true; d[j+a[i]]:=i; end; i:=10000; while not f[i] do dec(i); print(i); until false; end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator