#P12397. 「FAOI-R9」函数大师
「FAOI-R9」函数大师
Description
Qingfeng denotes a function as the sum of each digit of in decimal. Formally, is defined as:
$$s(x) = \sum_{i=0} \left( \lfloor \frac{x}{10^i} \rfloor \bmod 10 \right).$$Consequently, he defines as follows:
$$S_k(x) = \begin{cases} x, & k = 0, \\ s(S_{k-1}(x)), & k > 0. \end{cases}$$Moreover, Qingfeng defines to be . After giving such a function to Mingyue, who confidently inputs the formula into the Geometer's Sketchpad and is dazzled by the graphics, Mingyue decides to ask you to find out the properties of the function.
To be specific: you are given a constant integer . There are multiple queries, in each of them you are given another integer , and you have to find out the number of intersection points of the graphics of the functions and . It can be proven that the result is always finite under the given constraints.
Input Format
The first line contains two integers and , denoting the number of queries, and the given constant, respectively.
Then lines follow. Each line contains a single integer .
Output Format
For each query, output a single line containing an integer: the answer to the corresponding query.
4 3
21
20
19
50
1
1
0
1
Hint
Sample Description
For the first test case: the sets of the x - coordinates of all the intersection points corresponding to each group of data are , , , and , respectively.
Constraints
Subtasks are used in this problem.
- Subtask 1(5 pts): .
- Subtask 2(20 pts): , , .
- Subtask 3(25 pts): , , .
- Subtask 4(25 pts): .
- Subtask 5(25 pts): No additional constraints.
For all test cases, it is guaranteed that , , .
京公网安备 11011102002149号