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 |
请大家帮忙看下,这"WRONG ANSWER"pascal的暴搜 program LL; type arr=array[1..10]of integer; var n,s,i:integer; b,z,t:arr; procedure work(x,L:longint;b:arr); var i,j,bj:integer; begin b[L]:=x; if L=n then begin z:=b; for j:=1 to n-1 do for i:=1 to n-j+1 do b[i]:=b[i]+b[i+1]; if b[1]=s then begin bj:=0; for i:=1 to n do if t[i]<z[i] then begin bj:=1; break; end else if z[i]<t[i] then begin bj:=2; break; end; if bj=1 then else if bj=2 then t:=z; end; exit; end; for i:=1 to 9 do begin bj:=0; for j:=1 to L do if i=b[j] then begin bj:=1; break; end; if bj=0 then work(i,L+1,b); end; end; begin readln(n,s); fillchar(t,sizeof(t),9); for i:=1 to 9 do begin fillchar(b,sizeof(b),0); work(i,1,b); end; for i:=1 to n do write(t[i],' '); end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator