102344: [AtCoder]ABC234 E - Arithmetic Number

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $500$ points

Problem Statement

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

  • Let $d_i$ be the $i$-th digit of $n$ from the top (when $n$ is written in base $10$ without unnecessary leading zeros.) Then, $(d_2-d_1)=(d_3-d_2)=\dots=(d_k-d_{k-1})$ holds, where $k$ is the number of digits in $n$.
    • This condition can be rephrased into the sequence $(d_1,d_2,\dots,d_k)$ being arithmetic.
    • If $n$ is a $1$-digit integer, it is assumed to be an arithmetic number.

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

Find the smallest arithmetic number not less than $X$.

Constraints

  • $X$ is an integer between $1$ and $10^{17}$ (inclusive).

Input

Input is given from Standard Input in the following format:

$X$

Output

Print the answer as an integer.


Sample Input 1

152

Sample Output 1

159

The smallest arithmetic number not less than $152$ is $159$.


Sample Input 2

88

Sample Output 2

88

$X$ itself may be an arithmetic number.


Sample Input 3

8989898989

Sample Output 3

9876543210

Input

题意翻译

一个正整数 $n$ 被称为等差数需要满足以下条件: - 令 $d_i$ 表示 $n$ 在十进制下从最高位开始的第 $i$ 位数字,即 $n = \overline{d_1d_2\cdots d_k}$,其中 $k$ 表示 $n$ 的位数。 - 并且,序列 $(d_1, d_2, \dots, d_k)$ 为等差数列。 - 若 $n$ 是一位整数,则它也被视作为等差数。 例如,$234,369,86420,17,95,8,11,777$ 是等差数,然而 $751,919,2022,246810,2356$ 不是等差数。 请你求出不小于 $X$ 的最小等差数。

Output

分数:500分

问题描述

我们称满足以下条件的正整数$n$为一个算术数

  • 当$n$以十进制表示且不包含不必要的前导零时,令$d_i$表示从最高位数起的第$i$个数字。则有$(d_2-d_1)=(d_3-d_2)=\dots=(d_k-d_{k-1})$成立,其中$k$为$n$的位数。
    • 这个条件可以重新表述为$(d_1,d_2,\dots,d_k)$是一个算术数列。
    • 如果$n$是一个一位数整数,我们假设它是算术数。

例如,$234,369,86420,17,95,8,11,777$是算术数,而$751,919,2022,246810,2356$不是。

找到不小于$X$的最小算术数。

限制条件

  • $X$是介于$1$和$10^{17}$(含)之间的整数。

输入

输入从标准输入以以下格式给出:

$X$

输出

将答案以整数形式打印出来。


样例输入 1

152

样例输出 1

159

不小于$152$的最小算术数是$159$。


样例输入 2

88

样例输出 2

88

$X$本身可能是一个算术数。


样例输入 3

8989898989

样例输出 3

9876543210

加入题单

算法标签: