#abc234e. E - Arithmetic Number

E - Arithmetic Number

Score : 500500 points

问题描述

让我们称满足以下条件的正整数 nn等差数

  • nn 以十进制表示且没有前导零时,令 did_i 表示从高位开始的第 ii 个数字。则有 (d2d1)=(d3d2)==(dkdk1)(d_2-d_1)=(d_3-d_2)=\dots=(d_k-d_{k-1}) 成立,其中 kknn 的位数。
    • 这个条件可以重述为序列 (d1,d2,,dk)(d_1,d_2,\dots,d_k) 是等差的。
    • nn 是一位数,则假设它是等差数。

例如,234,369,86420,17,95,8,11,777234, 369, 86420, 17, 95, 8, 11, 777 都是等差数,而 751,919,2022,246810,2356751, 919, 2022, 246810, 2356 则不是。

找出大于等于 XX 的最小的等差数。

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

Problem Statement

Let us call a positive integer nn that satisfies the following condition an arithmetic number.

  • Let did_i be the ii-th digit of nn from the top (when nn is written in base 1010 without unnecessary leading zeros.) Then, (d2d1)=(d3d2)==(dkdk1)(d_2-d_1)=(d_3-d_2)=\dots=(d_k-d_{k-1}) holds, where kk is the number of digits in nn.
    • This condition can be rephrased into the sequence (d1,d2,,dk)(d_1,d_2,\dots,d_k) being arithmetic.
    • If nn is a 11-digit integer, it is assumed to be an arithmetic number.

For example, 234,369,86420,17,95,8,11,777234,369,86420,17,95,8,11,777 are arithmetic numbers, while 751,919,2022,246810,2356751,919,2022,246810,2356 are not.

Find the smallest arithmetic number not less than XX.

Constraints

  • XX is an integer between 11 and 101710^{17} (inclusive).

Input

Input is given from Standard Input in the following format:

XX

Output

Print the answer as an integer.

Sample Input 1

152

Sample Output 1

159

The smallest arithmetic number not less than 152152 is 159159.

Sample Input 2

88

Sample Output 2

88

XX itself may be an arithmetic number.

Sample Input 3

8989898989

Sample Output 3

9876543210

update @ 2024/3/10 10:10:27