主题:最简表达式
ECLARE SUB hxy (x!)
CLS
DIM SHARED n, k, s, y AS DOUBLE
INPUT n
DO
k = k + 1
m = 2 ^ k - 1
LOOP UNTIL m >= n
DIM SHARED a(k)
hxy (1)
PRINT k; y
END
SUB hxy (x)
FOR i = s + 1 TO a(x - 1) + 1 STEP -1
a(x) = i
s = s + i
IF x < k THEN
hxy (x + 1)
ELSE
s = s - i
IF s + i >= n THEN
y = y + 1
ELSE
EXIT FOR
END IF
END IF
NEXT i
s = s - a(x - 1)
END SUB
CLS
DIM SHARED n, k, s, y AS DOUBLE
INPUT n
DO
k = k + 1
m = 2 ^ k - 1
LOOP UNTIL m >= n
DIM SHARED a(k)
hxy (1)
PRINT k; y
END
SUB hxy (x)
FOR i = s + 1 TO a(x - 1) + 1 STEP -1
a(x) = i
s = s + i
IF x < k THEN
hxy (x + 1)
ELSE
s = s - i
IF s + i >= n THEN
y = y + 1
ELSE
EXIT FOR
END IF
END IF
NEXT i
s = s - a(x - 1)
END SUB