luogu#P3362. Cool loves shaxian
Cool loves shaxian
Background
Cool really, really loves eating at Shaxian. To be precise, he really, really likes dragging all kinds of unsuspecting folks to Shaxian for meals (╯‵□′)╯(┻━┻. Everyone is dying to know how much money Shaxian has paid Cool to "endorse" (dàiyán) Shaxian Snacks, so that in the future they can threaten and cajole Cool into treating them to the KFC next door. After much tracking, people discovered some patterns in how the endorsement fees are paid out ヾ(o◕∀◕)ノヾ。
Problem Description
Shaxian is famous for being lavish when paying endorsement (dàiyán) fees. When this Shaxian pays endorsement fees, it uses an exponent . It will pay fees for rounds. In the -th round, it pays money.
Now there are queries. Each query asks: if Cool participates from round to round , how much money will he receive? (It is guaranteed that .)
Since the Shaxian Snacks on South Street is insanely rich, we need to compute the answer modulo .
Input Format
The input contains multiple lines.
The first line contains three integers, (, , ).
The next lines each contain two integers .
Output Format
The output contains lines.
Each line contains one integer, the amount of endorsement fee Cool receives.
10 2 2
4 5
8 10
47
306
1000 0 1
720 720
30
Hint
Sample 1:
.
.
.
Sample 2:
This is essentially the number of divisors of the number ~.
Translated by ChatGPT 5