#P8482. 「HGOI-1」Number

    ID: 9358 远端评测题 750ms 256MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>贪心高精度洛谷原创Special JudgeO2优化洛谷月赛

「HGOI-1」Number

Background

bh1234666\text{bh1234666} is learning multiplication.

Problem Description

bh1234666\text{bh1234666} has a certain number of digits 090 \sim 9. Now he wants you to find an allocation scheme that splits them into two integers so that their product pp is maximized.

Since bh1234666\text{bh1234666} does not like numbers that are too large, you only need to output two non-negative integers such that their product is equal to the maximum product pp, but the counts of digits 090 \sim 9 used in these two integers must not be equal to the given counts (it is enough that the count of any one digit is different; leading zeros are not considered).

bh1234666\text{bh1234666} is very kind: if the counts of 090 \sim 9 are exactly the same as the given counts, you can still get half of the points.

Input Format

The first line contains ten integers c0,c1,c9c_0,c_1,\cdots c_9, representing the counts of digits 090 \sim 9, respectively.

Output Format

Two lines, each containing a non-negative integer, representing the two non-negative integers you provide.

1 2 3 2 1 1 2 1 2 1
13949030
620572547

Hint

Sample Explanation

The maximum possible product is $97643210 \times 88653221=13949030 \times 620572547=8656385075279410$.

If you output 97643210×8865322197643210 \times 88653221, you can only get half of the points, because the number of occurrences of 090\sim 9 is the same as the given one.

Constraints and Notes

This problem uses bundled tests. There are 55 subtask\text{subtask} in total, and the final score is the sum of the scores of all subtask\text{subtask}.

$$\def\arraystretch{1.5} \begin{array}{|c|c|c|}\hline \textbf{Task} & \textbf{Score} & \sum c_i\le \cr\hline 1 & 10 & 20 \cr\hline 2 & 20 & 100 \cr\hline 3 & 20 & 5000 \cr\hline 4 & 20 & 10^6 \cr\hline 5 & 30 & 10^7 \cr\hline \end{array}$$

For 100%100\% of the testdata, it is guaranteed that 1ci1 \le c_i and ci107\sum c_i \le 10^7.

Notes

This problem has an spj\text{spj}. If the product of the two numbers is correct, you get half of the points; if the digit counts are different from the given ones and the product is correct, you get full points. Therefore, for each subtask\text{subtask}, the score is the minimum value among the scores of all test points in it.

Input Format

The first line contains ten integers c0,c1,c9c_0,c_1,\cdots c_9, representing the counts of digits 090 \sim 9, respectively.

Output Format

Two lines, each containing a non-negative integer, representing the two non-negative integers you provide.

Translated by ChatGPT 5