200753: [AtCoder]ARC075 F - Mirrored

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

Description

Score : $800$ points

Problem Statement

For a positive integer $n$, we denote the integer obtained by reversing the decimal notation of $n$ (without leading zeroes) by $rev(n)$. For example, $rev(123) = 321$ and $rev(4000) = 4$.

You are given a positive integer $D$. How many positive integers $N$ satisfy $rev(N) = N + D$?

Constraints

  • $D$ is an integer.
  • $1 ≤ D < 10^9$

Input

Input is given from Standard Input in the following format:

$D$

Output

Print the number of the positive integers $N$ such that $rev(N) = N + D$.


Sample Input 1

63

Sample Output 1

2

There are two positive integers $N$ such that $rev(N) = N + 63$: $N = 18$ and $29$.


Sample Input 2

75

Sample Output 2

0

There are no positive integers $N$ such that $rev(N) = N + 75$.


Sample Input 3

864197532

Sample Output 3

1920

Input

题意翻译

给定 $D$,求满足 $\mathrm{rev}(N)=N+D$ 的 $N$ 的个数,$\mathrm{rev}(N)$ 表示十进制下将 $N$ 按位翻转并去掉前导 $0$ 后的数。

加入题单

上一题 下一题 算法标签: