|
|
вернуться в форумPlease Helppppp!!!!! It's still WA on test #11! Here is my code on pascal: ****************************** var n,i,k,j,min:integer; a:array [0..10000] of 0..2; b:array [0..50] of integer; q:boolean; Procedure init; Begin fillchar(a,sizeof(a),0); readln(n,k); read(b[1]); min:=b[1]; for i:=2 to k do begin read(b[i]); if b[i]<min then min:=b[i] end; a[min]:=1; for i:=1 to k do a[min+b[i]]:=2; End; Procedure set_a; Begin q:=false; for j:=1 to k do if i-b[j]>=min then if a[i-b[j]]=1 then begin q:=true; break end; if q then a[i]:=2 else Begin a[i]:=1; for j:=1 to k do if i+b[j]<=10000 then a[i+b[j]]:=2; End; End; Procedure main; Begin For i:=min+1 to n do if a[i]=0 then set_a; End; Procedure out; Begin if a[n]=1 then write(2) else write(1); End; BEGIN init; main; out; END. ******************************** |
|
|