luogu#P5518. [MtOI2019] 幽灵乐团 / 莫比乌斯反演基础练习题
[MtOI2019] 幽灵乐团 / 莫比乌斯反演基础练习题
Background
In Hakugyokurou, the concert in the Netherworld has begun.
Lunasa, Lyrica, and Merlin are performing.
Problem Description
Kochiya Sanae really likes the performance of the Ghost Band, and she wants to score their performance.
Since the Ghost Band has members, we can use three positive integers to represent the score of the band’s performance. Their performance score can be written as
$$\prod_{i=1}^{A}\prod_{j=1}^{B}\prod_{k=1}^{C}\left(\frac{\text{lcm}(i,j)}{\gcd(i,k)}\right)^{f(type)}$$Because the music sounds different in different parts, changes within , where:
$$\begin{aligned} f(0)&=1 \cr f(1)&=i \times j \times k \cr f(2)&=\gcd(i,j,k) \end{aligned}$$Because the band’s songs are so good that the score becomes very large, the score should be taken modulo a given positive integer .
Since there are many songs to perform, Sanae gives queries.
Input Format
The first line contains two positive integers and , as described above.
The next lines each contain three positive integers , representing one query.
Output Format
Output lines. Each line contains three positive integers, representing the value of the given expression when , respectively.
3 998244853
1 1 1
2 2 2
3 3 3
1 1 1
16 4096 16
180292630 873575259 180292630
Hint
Constraints and Notes
For of the testdata:
For of the testdata:
Another of the testdata:
For of the testdata:
For of the testdata:
$$1\leq A,B,C\leq 10^5 \ \ \ \ 10^7 \leq p \leq 1.05\times 10^9\ \ \ \ p\in \{ prime\} \ \ \ \ T =70$$Sanae is very kind. Even if you do not know all the correct answers, she will still give you some points.
- If your first column is correct, she will give you of the score for this test point.
- If your second column is correct, she will give you of the score for this test point.
- If your third column is correct, she will give you of the score for this test point.
So even if you do not know what the answers are, please output an integer in for the parts you do not know, otherwise it may cause unpredictable errors.
Source
Lost House 2019 League (MtOI2019) T5.
Problem setter: CYJian.
Translated by ChatGPT 5