#abc363d. D - Palindromic Number

D - Palindromic Number

Score : 350350 points

问题陈述

一个非负整数 XX 如果其十进制表示(不包含前导零)是一个回文数,则称为回文数。 例如,363363123443211234432100 都是回文数。

找出第 NN 个最小的回文数。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

A non-negative integer XX is called a palindrome number if its decimal representation (without leading zeros) is a palindrome.
For example, 363363, 1234432112344321, and 00 are all palindrome numbers.

Find the NN-th smallest palindrome number.

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • NN is an integer.

Input

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

NN

Output

Print the NN-th smallest palindrome number.

Sample Input 1

46

Sample Output 1

363

The 46th smallest palindrome number is 363363.

Sample Input 2

1

Sample Output 2

0

Sample Input 3

1000000000000000000

Sample Output 3

90000000000000000000000000000000009