CF509C.Sums of Digits

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya had a strictly increasing sequence of positive integers _a_1, ..., a__n. Vasya used it to build a new sequence _b_1, ..., b__n, where b__i is the sum of digits of a__i's decimal representation. Then sequence a__i got lost and all that remained is sequence b__i.

Vasya wonders what the numbers a__i could be like. Of all the possible options he likes the one sequence with the minimum possible last number a__n. Help Vasya restore the initial sequence.

It is guaranteed that such a sequence always exists.

瓦西娅原本有一个严格递增的正整数序列 a1,…,ana_1, \dots, a_n。他利用该序列构造了一个新序列 b1,…,bnb_1, \dots, b_n,其中 bib_i 是 aia_i 的十进制表示中各位数字之和。随后,序列 aia_i 遗失了,仅剩下序列 bib_i。

瓦西娅想知道原来的 aia_i 可能是什么样的。在所有可能的选项中,他偏爱最后一个数 ana_n 尽可能小的那个序列。请帮助瓦西娅恢复原始序列。

题目保证这样的序列一定存在。

输入格式

The first line contains a single integer number n (1 ≤ n ≤ 300).

Next n lines contain integer numbers _b_1, ..., b__n — the required sums of digits. All b__i belong to the range 1 ≤ b__i ≤ 300.

第一行包含一个整数 $ n (( 1 \leq n \leq 300 $)。

接下来的 $ n $ 行每行包含一个整数 $ b_1, \dots, b_n $ —— 所需的各位数字之和。所有 $ b_i $ 均满足 $ 1 \leq b_i \leq 300 $。

输出格式

Print n integer numbers, one per line — the correct option for numbers a__i, in order of following in sequence. The sequence should be strictly increasing. The sum of digits of the i-th number should be equal to b__i.

If there are multiple sequences with least possible number a__n, print any of them. Print the numbers without leading zeroes.

输出 n 个整数,每行一个——即满足条件的数字 a__i 的正确取值,按其在序列中出现的顺序输出。该序列必须严格递增。第 i 个数的各位数字之和应等于 b__i。

若存在多个满足条件且 a__n 最小的序列,则输出其中任意一个即可。输出的数字不得包含前导零。

输入输出样例

  • 输入#1

    3
    1
    2
    3

    输出#1

    1
    2
    3
  • 输入#2

    3
    3
    2
    1

    输出#2

    3
    11
    100

输入解题思路,AI测评打分。不知道怎么写?

首页