No.3548 SigMax Digits (Construction ver.)
Problem Statement
For a positive integer $n$, let $f(n)$ be the maximum digit contained in the decimal representation of $n$.
For example, $f(314) = 4, ~ f(10) = 1, ~ f(998244353) = 9$.
You are given a positive integer $N$.
Find one pair of integers $L, R$ satisfying $1 \leq L \leq R \leq 10^{18}$ such that $f(L) + f(L + 1) + \cdots + f(R) = N$.
Under the constraints of this problem, it is guaranteed that $L, R$ satisfying the conditions always exist.
You are given $T$ test cases; answer each of them.
Constraints
- All input values are integers
- $1 \leq T \leq 10^5$
- $1 \leq N \leq \color{red}{10^{17}}$
Input
The input is given from standard input in the following format. Here, the $t ~ (1 \leq t \leq T)$-th test case is denoted by $\mathrm{case}_t$.
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$N$
Output
Output $T$ lines. On the $t$-th line, output the answer for the $t$-th test case.
For each test case, output $L, R$ forming the answer, in this order, separated by a space.
If there are multiple answers, any of them will be accepted.
Sample
Sample 1
Input
3 23 5 99999999999999999
Output
58 60 5 5 888888888888888890 900000000000000000
For the $1$-st test case, $f(58) + f(59) + f(60) = 8 + 9 + 6 = 23$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ぽえ