3 var f : array [0..10000000] of boolean;
\r
4 i, k, j, p : integer;
\r
6 a, b : array [1..10000] of integer;
\r
8 procedure add (s : string);
\r
10 f[strtoint (s)] := true;
\r
14 randseed := 23478432;
\r
15 for i := 1 to 50 do begin
\r
16 j := random (9999909) + 1;
\r
17 for k := 1 to 50 do
\r
22 for k := 1 to 9999999 do
\r
25 for j := 1 to length (s) do begin
\r
26 if s[j] = '1' then begin
\r
27 s[j] := '3'; add (s);
\r
28 s[j] := '7'; add (s);
\r
31 if s[j] = '3' then begin
\r
32 s[j] := '1'; add (s);
\r
33 s[j] := '7'; add (s);
\r
36 if s[j] = '7' then begin
\r
37 s[j] := '3'; add (s);
\r
38 s[j] := '7'; add (s);
\r
41 if s[j] = '2' then begin
\r
42 s[j] := '9'; add (s);
\r
45 if s[j] = '9' then begin
\r
46 s[j] := '2'; add (s);
\r
49 if s[j] = '4' then begin
\r
50 s[j] := '5'; add (s);
\r
51 s[j] := '6'; add (s);
\r
54 if s[j] = '5' then begin
\r
55 s[j] := '4'; add (s);
\r
56 s[j] := '6'; add (s);
\r
59 if s[j] = '6' then begin
\r
60 s[j] := '4'; add (s);
\r
61 s[j] := '5'; add (s);
\r
68 for i := 1 to 1000000 do
\r
69 if f[i] <> f[i - 1] then begin
\r
70 if f[i] then begin inc (p); a[p] := i end else b[p] := i - 1;
\r
74 writeln (a[i], ' ', b[i]);
\r