VAR

n: INT64;

l: LONGINT;

a: ARRAY[0..9] OF LONGINT;

b: ARRAY[1..3000] OF INT64;

FUNCTION f01(ss: STRING): INT64;

VAR

i, j, code: LONGINT;

n0, n1: INT64;

s1, s2: STRING;

BEGIN

FILLCHAR(a, SIZEOF(a), 0);

FOR i:=1 TO l DO INC(a[ORD(ss[i]) - 48]);

s1 := ''; s2 := '';

FOR i:=1 TO 9 DO

FOR j:=1 TO a[i] DO s1 := s1 + CHR(i + 48);

FOR i:=9 DOWNTO 0 DO

FOR j:=1 TO a[i] DO s2 := s2 + CHR(i + 48);

VAL(s1, n0, code); VAL(s2, n1, code);

EXIT(n1 - n0);

END;

PROCEDURE xxx;

VAR

i, j, k: LONGINT;

m: INT64;

s0: STRING;

BEGIN

m := n; STR(n, s0); l := LENGTH(s0);

i := 1; b[1] := m;

REPEAT

STR(m, s0);

WHILE LENGTH(s0) < l DO s0 := '0' + s0;

m := f01(s0);

FOR j:=1 TO i DO

IF b[j] = m THEN BEGIN

FOR k:=j TO i - 1 DO WRITE(b[k], ' ');

WRITELN(b[i]);

EXIT;

END;

INC(i); b[i] := m;

UNTIL FALSE;

END;

BEGIN

WHILE NOT EOF(input) DO BEGIN

FILLCHAR(b, SIZEOF(b), 0);

READ(n);

xxx;

END;

END.

{AAAAA}

{AAAAA}

全是比标准输出长。

0 条评论

目前还没有评论...

信息

ID
1024
难度
6
分类
模拟 点击显示
标签
(无)
递交数
6785
已通过
1570
通过率
23%
被复制
14
上传者