Magic
Time limit1sMemory limit128 MB
Given Y, count natural numbers X whose decimal digits reversed and added back to X give exactly Y.
- Level
Medium6 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Mirko has thought of a top-secret natural number that holds the secret of ruling the universe. His best friend Slavko is drunk with power and wants to get hold of that number. While searching Mirko's drawers late at night, Slavko found a slip of paper. It says that the sum of and the mirror of is exactly .
The mirror of is formed by writing the decimal digits of in reverse order. For example, the mirror of is , and the mirror of is .
For a given , compute how many natural numbers satisfy this condition.
Input
The first line contains (), the number of test cases you must answer.
Each of the next lines contains one natural number (), as described in the statement.
Output
For each of the numbers , print one line with the number of distinct values of that produce exactly that .
The answer for each is completely independent of the lines before and after it in the input.
Hint