AtCoder Regular Contest 123
翻译中…
Problem Statement
翻译中…
Given is a positive integer $N$. Consider a sequence of integers $A = (A_1, \ldots, A_K)$ that satisfies the conditions below:
翻译中…
$\sum_{i=1}^K A_i = N$;- each
$A_i$is a positive integer such that every digit in its decimal notation is$1$,$2$, or$3$.
翻译中…
Find the minimum possible value of $K$, that is, the number of elements in such a sequence $A$.
翻译中…
Process $T$ test cases per input file.
翻译中…
Constraints
翻译中…
$1\leq T\leq 1000$$1\leq N\leq 10^{18}$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
翻译中…
Each case is in the following format:
翻译中…
N
翻译中…
Output
翻译中…
Print the answers.
翻译中…
样例
Input #1
5
456
10000
123
314
91
Output #1
2
4
1
2
4
For each $N$, one optimal $A$ is shown below.
- For $N = 456$: $A = (133, 323)$.
- For $N = 10000$: $A = (323, 3132, 3232, 3313)$.
- For $N = 123$: $A = (123)$.
- For $N = 314$: $A = (312,2)$.
- For $N = 91$: $A = (22,23,23,23)$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。