問題一覧 > 通常問題

No.1953 8

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 52
作問者 : H20 / テスター : 蜜蜂 👑 Kazun
お気に入りにしたユーザー ProblemId : 8024 / 自分の提出
問題文最終更新日: 2022-05-21 00:50:28
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 344 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。