|
|
back to boardSOS!!!Why I got WA.This is my program: SOS!!!Why I got WA.This is my program: const MAX = 20; var List : array [0 .. 9, 1 .. MAX] of shortint; Num : array [1 .. MAX, 1 .. 2] of shortint; s : set of 1 .. MAX; i, j, t, n : longint; c : char; b : boolean; Procedure Out; var oi, oj : integer; begin for oi := t downto 1 do for oj := 1 to t do begin if Num [oj, 2] = oi then write (Num [oj, 1]); end; writeln; end; Procedure Search (st, ss : longint); var sf, sa, si : longint; begin if Num [st, 1] >0 then sf := t else sf := t - 1; for si := 1 to sf do if (not (si in s)) and b then begin s := s + [si]; Num [st, 2] := si; sa := List [Num [st, 1], si]; if st < t then Search (st + 1, (ss + sa) mod 7); if (st = t) and ((ss + sa) mod 7 = 0) then begin Out; b := false; end; s := s - [si]; end; end; begin for i := 0 to 9 do begin t := i mod 7; List [i, 1] := t; for j := 2 to 20 do begin t := (t * 10) mod 7; List [i, j] := t; end; end; readln (n); for i := 1 to n do; begin b := true; s := []; t := 0; read(c); while c in ['0' .. '9'] do begin t := t + 1; Num [t, 1] := ord (c) - 48; read (c); end; Search (1, 0); end; end. |
|
|