No.3625 Find Superfibonacci Number
Problem Statement
You are given a positive integer $K$. Find the smallest positive integer $n$ that satisfies all of the following conditions.
- The digit sum of $n$ is $K$.
- Let $n_i$ denote the value of the $10^i$ place of $n$ when interpreted as a decimal number. Then there exists a non-negative integer $i$ such that $n_{i+2} \gt n_{i+1} + n_i$.
You are given $T$ test cases; answer each of them.
Constraints
- All input values are integers.
- $1 \leq T \leq 1000$
- $1 \leq K \leq 10^6$
- The sum of $K$ over all test cases is at most $10^6$.
Input
The input is given from Standard Input in the following format.
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$K$
Output
Print the answers to the test cases in order, separated by newlines.
Sample
Sample 1
Input
3 4 1 18
Output
301 100 1908
For the $1$st test case, the digit sum of $301$ is $4$, and $3 > 0 + 1$ holds for $i = 0$.
Thus, $301$ satisfies the conditions. No positive integer less than or equal to $300$ satisfies the conditions, so the answer is $301$.
For the $3$rd test case, when $n = 1908$, $n_{i + 2} > n_{i + 1} + n_i$ does not hold for $i = 1$, but it holds for $i = 0$.
The digit sum is $18$, so this satisfies the conditions.
Note that the answer may be $2^{64}$ or greater.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ぽえ
kazuppa