Type: Default 1000ms 256MiB

最大数

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

求能组成的最大数是多少.

题目描述

给你一个整数 nn, 我们希望组成一个最大的十进制数字.

  • 这个十进制数字的数位之和为 nn
  • 不能存在某一位数字为 0
  • 相邻两位不同.

数据格式

输入格式

第一行输入一个整数 tt, 表示有 tt 组数据.

接下来每组数据, 第一行输入一个整数 nn

输出格式

输出 tt 行, 每行一个整数表示最大值

样例

3
3
4
5
21
121
212

数据范围

1<=t<=10001 <= t <= 1000

1<=n<=10001 <= n <= 1000

[北辰杯 North-Star-Cup] 七月入门赛

Not Attended
Status
Done
Rule
Ledo
Problem
6
Start at
2023-7-21 18:00
End at
2023-7-22 0:00
Duration
6 hour(s)
Host
Partic.
91