#P10117. [LMXOI Round 1] Dreamer
[LMXOI Round 1] Dreamer
Background
This is a math problem, but it was made by LMX for HQZ.
Problem Description
Define the multiplicative function .
Given , you need to compute
$$\sum_{i_1\mid n}\sum_{i_2\mid i_1}\cdots\sum_{i_k\mid i_{k-1}}f(i_k)i_1i_k\mu^2\left(\dfrac{i_1}{i_k}\right)$$Tips
denotes the Möbius function.
For , we have $f(n)=\displaystyle \sum_{d\mid n}\mu(d)\left(\dfrac{n}{d}\right)^2$.
Input Format
This problem has multiple test cases. The first line contains a positive integer , the number of test cases.
Since is very large, we will give the standard prime factorization of .
For each query, we first give two integers .
The second line contains , and the next lines each contain two integers .
(It is guaranteed that for , and .)
Output Format
For each query, output one line: the answer modulo .
5
3 998244353
3
3 2
5 1
7 1
4 1000000009
2
2 1
3 2
1 998244353
2
2 2
3 1
11451 191981012
11
2 1
3 1
5 1
7 1
11 1
13 1
17 1
19 1
23 1
29 1
31 1
514 520
2
2 10
3 10
189282114
124678
14965
82966193
260
Hint
For of the testdata, $T \le 20,n\le 10^{24},1\le k\le 10^6,m\le 1.14\times 10^9$.
| Test Point ID | Special Property | |||
|---|---|---|---|---|
Property : It is guaranteed that .
Property : In the prime factorization of , .
Property : is prime, and it is guaranteed that .
Translated by ChatGPT 5