3 var f : array [0..1000000] 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
15 f[random (999999) + 1] := true;
\r
17 for i := 1 to 1000 do
\r
18 for k := 1 to 999999 do
\r
21 for j := 1 to length (s) do begin
\r
22 if s[j] = '1' then begin
\r
23 s[j] := '3'; add (s);
\r
24 s[j] := '7'; add (s);
\r
27 if s[j] = '3' then begin
\r
28 s[j] := '1'; add (s);
\r
29 s[j] := '7'; add (s);
\r
32 if s[j] = '7' then begin
\r
33 s[j] := '3'; add (s);
\r
34 s[j] := '7'; add (s);
\r
37 if s[j] = '2' then begin
\r
38 s[j] := '9'; add (s);
\r
41 if s[j] = '9' then begin
\r
42 s[j] := '2'; add (s);
\r
49 for i := 1 to 1000000 do
\r
50 if f[i] <> f[i - 1] then begin
\r
51 if f[i] then begin inc (p); a[p] := i end else b[p] := i - 1;
\r
55 writeln (a[i], ' ', b[i]);
\r