#P8116. 「Wdoi-1.5」魔理沙的计算器

    ID: 6693 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数论洛谷原创O2优化洛谷月赛

「Wdoi-1.5」魔理沙的计算器

Description

Marisa's calculator can perform computations in base bb, and the screen can display kk digits (not including the decimal point). After a computation, if some digits exceed the screen capacity, they are directly discarded (for example, when b=10b=10, 1÷7=0.1428571\div 7=0.142857\cdots; if the screen size is 44, then the final display is 0.1420.142).

Marisa uses the calculator to compute 1÷n=n1\div n=n', and then computes 1÷n=n1\div n'=n'' (nn' and nn'' are both the results shown on the screen). Marisa wants to know how many positive integers nn satisfy n=nn=n''. You only need to output this count modulo 998,244,353998,244,353.

Input Format

  • The first line contains a positive integer TT, the number of test cases.
  • The next TT lines each contain two positive integers b,kb,k, representing the calculator's base and the number of digits the screen can display.

Output Format

  • Output TT lines in total.
  • Each line outputs one integer. The integer on the ii-th line is the number of valid nn in the ii-th test case, modulo 998,244,353998,244,353.
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 1,2,41,2,4.
  • For the second query, the numbers that satisfy the condition (converted to decimal) are 1,5,251,5,25.

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 100%100\% of the testdata, it holds that 1T101\le T\le 10, 2b1052\le b\le 10^5, 1k5001\le k\le 500.

Translated by ChatGPT 5