C - Repunit Trio Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 300300

問題文

十進法ですべての桁の数字が 11 である整数をレピュニットと呼びます。レピュニットを小さい順に並べると 1,11,111,1,11,111,\ldots です。

ちょうど 33 つのレピュニットの和として表せる整数のうち NN 番目に小さいものを求めてください。

制約

  • NN11 以上 333333 以下の整数

入力

入力は以下の形式で標準入力から与えられる。

NN

出力

答えを出力せよ。


入力例 1Copy

Copy
5

出力例 1Copy

Copy
113

ちょうど 33 つのレピュニットの和として表せる整数を小さい順に並べると 3,13,23,33,113,3,13,23,33,113,\ldots です。例えば 113113113=1+1+111113=1+1+111 と表せます。

33 つのレピュニットは相異ならなくてもよいことに注意してください。


入力例 2Copy

Copy
19

出力例 2Copy

Copy
2333

入力例 3Copy

Copy
333

出力例 3Copy

Copy
112222222233

Score : 300300 points

Problem Statement

A repunit is an integer whose digits are all 11 in decimal representation. The repunits in ascending order are 1,11,111,1, 11, 111, \ldots.

Find the NN-th smallest integer that can be expressed as the sum of exactly three repunits.

Constraints

  • NN is an integer between 11 and 333333, inclusive.

Input

The input is given from Standard Input in the following format:

NN

Output

Print the answer.


Sample Input 1Copy

Copy
5

Sample Output 1Copy

Copy
113

The integers that can be expressed as the sum of exactly three repunits are 3,13,23,33,113,3, 13, 23, 33, 113, \ldots in ascending order. For example, 113113 can be expressed as 113=1+1+111113 = 1 + 1 + 111.

Note that the three repunits do not have to be distinct.


Sample Input 2Copy

Copy
19

Sample Output 2Copy

Copy
2333

Sample Input 3Copy

Copy
333

Sample Output 3Copy

Copy
112222222233


2025-04-24 (Thu)
06:22:52 +00:00