#P8116. 「Wdoi-1.5」魔理沙的计算器
「Wdoi-1.5」魔理沙的计算器
Description
Marisa's calculator can perform computations in base , and the screen can display digits (not including the decimal point). After a computation, if some digits exceed the screen capacity, they are directly discarded (for example, when , ; if the screen size is , then the final display is ).
Marisa uses the calculator to compute , and then computes ( and are both the results shown on the screen). Marisa wants to know how many positive integers satisfy . You only need to output this count modulo .
Input Format
- The first line contains a positive integer , the number of test cases.
- The next lines each contain two positive integers , representing the calculator's base and the number of digits the screen can display.
Output Format
- Output lines in total.
- Each line outputs one integer. The integer on the -th line is the number of valid in the -th test case, modulo .
3
4 2
5 3
12 99
3
3
19503
Hint
Sample Explanation
- For the first query, the numbers that satisfy the condition (converted to decimal) are .
- For the second query, the numbers that satisfy the condition (converted to decimal) are .
Constraints and Conventions
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|}\hline \textbf{subtask}&\textbf{Score} & \bm{b\le} & \bm {k\le } & \textbf{Special Properties} & \textbf{subtask Dependencies} \cr\hline 1 & 20 & 10 & 7 & - &-\cr\hline 2 & 20 & 10^5 & 2 & k=2&-\cr\hline 3 & 10 & 10^5 & 3 & k=3&- \cr\hline 4 & 50& 10^5 & 500 & -&1,2,3\cr\hline \end{array}$$For of the testdata, it holds that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号