1889Increasing Sequences

1889   Increasing Sequences

题目描述

Given a string of digits, insert commas to create a sequence of strictly increasing numbers so as to minimize the magnitude of the last number. For this problem, leading zeros are allowed in front of a number.

输入格式:

Input will consist of multiple test cases. Each case will consist of one line, containing a string of digits of maximum length 80. A line consisting of a single 0 terminates input.

输出格式:

For each instance, output the comma separated strictly increasing sequence, with no spaces between commas or numbers. If there are several such sequences, pick the one which has the largest first value; if there‘s a tie, the largest second number, etc.

输入样例 复制
3456
3546
3526
0001
100000101
0
输出样例 复制
3,4,5,6
35,46
3,5,26
0001
100,000101

说明

2
2
通过提交
时空限制10000ms/32mb
题目来源East Central North America 2002
评测方式在线评测
题目类型
难        度