#P8116. Marisa's Calculator and Inverse Operation
Marisa's Calculator and Inverse Operation
Marisa's Calculator and Inverse Operation
Marisa has a peculiar calculator that works in base \(b\) and can display exactly \(k\) digits (excluding the decimal point). When a calculation produces more than \(k\) digits, the extra digits are directly truncated (i.e. no rounding is performed). For example, in base \(10\) we have \(1 \div 7 = 0.142857\cdots\); if the screen can show \(4\) digits then the display will show 0.142
(the integer part and as many fractional digits as possible so that the total number of digits is \(4\)).
Marisa carries out the following two-step operation on a positive integer \(n\):
- First, she computes \(n' = T(1\div n)\), where \(T(x)\) means that the number \(x\) is represented in base \(b\) and then truncated to keep only the first \(k\) digits (ignoring the decimal point).
- Then she computes \(n'' = T(1\div n')\).
Marisa is curious about the fixed points of this two-step process; that is, for how many positive integers \(n\) does it hold that \(n = n''\)? It turns out that when \(n \ge 2\) (so that \(1\div n < 1\) and the display shows a leading zero for the integer part), the truncation procedure is equivalent to taking the first \(k-1\) digits of the fractional part. In this case one may show that writing
[ n' = \frac{\lfloor b^{k-1}/n \rfloor}{b^{k-1}}, \quad \text{and} \quad n'' = T\Bigl(\frac{b^{k-1}}{\lfloor b^{k-1}/n \rfloor}\Bigr), ]
we have \(n = n''\) if and only if \(n\) divides \(b^{k-1}\). (The case \(n=1\) is trivial.) Therefore, the answer to the problem is equal to the number of positive divisors of \(b^{k-1}\); specifically, if the prime factorization of \(b\) is
[ b = p_{1}^{a_{1}} p_{2}^{a_{2}} \cdots p_{r}^{a_{r}}, ]
then \(b^{k-1}=p_{1}^{a_{1}(k-1)} p_{2}^{a_{2}(k-1)} \cdots p_{r}^{a_{r}(k-1)}\) and its number of positive divisors is
[ \prod_{i=1}^{r} \Bigl(a_{i}(k-1)+1\Bigr). ]
Your task is to compute the above product modulo \(998\,244\,353\).
inputFormat
The input consists of a single line containing two integers \(b\) and \(k\) (with \(b \ge 2\) and \(k \ge 1\)), where \(b\) is the base in which the calculator works and \(k\) is the total number of digits available on the display.
outputFormat
Output a single integer: the number of positive integers \(n\) for which the two-step operation yields \(n = n''\), modulo \(998\,244\,353\). As explained in the description, this is equal to the number of divisors of \(b^{k-1}\).
sample
10 4
100