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 |
哪位大牛能帮我看看这个pascal程序有哪里错了!...var i,j,n,m:longint; ans:int64; f:array[0..100001,0..1] of boolean; a:array[0..100001] of longint; procedure qsort(l,r:longint); var i,j,k:longint; begin if l>=r then exit; i:=l; j:=r; k:=a[random(r-l)+l]; while i<=j do begin while a[i]<k do inc(i); while a[j]>k do dec(j); if i<=j then begin a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0]; inc(i); dec(j); end; end; qsort(i,r); qsort(l,j); end; begin readln(n,m); randomize; while n+m<>0 do begin fillchar(f,sizeof(f),false); f[0,0]:=true; for i:=1 to n do read(a[i]); qsort(1,n); for i:=1 to n do for j:=m downto a[i] do begin f[j,0]:=f[j-a[i],1]; f[j,1]:=f[j-a[i],0]; end; ans:=0; for i:=1 to m do if (f[i,1]) and (not f[i,0]) then ans:=ans+1; writeln(ans); readln(n,m); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator