Reverse Numbers
Time limit1sMemory limit32 MB
Given up to 10000-digit numbers M, decide whether some N satisfies M = N + Rev(N).
- Level
Medium7 of 10
- Topics
- String, Math, Implementation
- Solved
- No attempts yet
Problem
Numbers have many interesting properties. In this problem we look at one of them.
First, let us define the reverse of a number. For a number written in decimal as , its reverse is the number obtained by writing the digits in the opposite order; we denote it . Any leading zeros produced this way are dropped. For example, and .
You are given several natural numbers. For each number , decide whether there exists a natural number such that .
Input
The input consists of at most 10001 lines. Each line contains one positive integer with fewer than 10000 digits. The last line contains the number , which must not be processed.
Output
For each number in the input, print YES on its own line if there exists a natural number with , and NO otherwise.