No.1953 8
Problem Statement
DHMO wrote every integer from $1$ to $N$ inclusive on paper, once each, in decimal notation.
Viewed as figures, they contained $K$ circles (regions enclosed by lines).
$K$ is given as input. Output a possible value of $N$ in this situation.
However, if no $N$ satisfies the condition, output -1.
Also, if multiple numbers satisfy the condition, output any one of them.
The shape of each digit is as shown below. Although the shape is a bit odd, 4 is considered to contain one circle.
Input
$K$
Constraints
- $ 0 \le K \le 10^{18}$
- All inputs are integers.
Output
If an $N$ satisfying the condition exists, output $N$.
If no $N$ satisfies the condition, output -1.
Print a newline at the end.
Sample
Sample 1
Input
8
Output
17
$1234567891011121314151617$ contains $8$ circles.
Outputting $16$ is also accepted.
Sample 2
Input
88888
Output
-1
No $N$ satisfies the condition.
Sample 3
Input
999999999999999993
Output
99193752409910740
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
H20
蜜蜂
Kazun