King Sam and Strange Function

3.7

46 votes
Easy
Problem

King Sam loves to play with numbers. This time he came to know about an amazing function F(x) which sums digits of a number 'x'. For example, when x = 2344, F(x) = 13. Now using composite function, he created a problem.

Given a positive integer N, find out how many positive integers X satisfy the equation

X + F(X) + F(F(X)) + ..... + till (F(X) = X) = N .

Input Format:

The first line of input contains an integer T , no. of test-cases. Each of next T lines contain one integer number N.

Output Format:

Output single integer in a line denoting the count of number of positive integers X satisfying the above given equation for each test-case.

Constraints:

1<= T <=10^4

1<= N <=10^15

Sample Input
2
6
11
Sample Output
1
1
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Testcase 2: 10 + 1 = 11

Contributers:
Editor Image

?