#abc333c. C - Repunit Trio

C - Repunit Trio

Score : 300300 points

问题陈述

在十进制表示中,一个repunit是指所有数字均为 11 的整数。按升序排列的repunit序列如下:1,11,111,1, 11, 111, \ldots

找出第 NN 个恰好可以用三个repunit之和表示的最小整数。

以上为通义千问 qwen-max 翻译,仅供参考。

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 1

5

Sample Output 1

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 2

19

Sample Output 2

2333

Sample Input 3

333

Sample Output 3

112222222233

update @ 2024/3/10 01:19:28