luogu#P4900. 食堂
食堂
Background
Even if I, CYJian, were to die, die outside, or jump off from here, I would still not eat a single bite of cafeteria food.
Problem Description
On day , the cafeteria has dishes. CYJian thinks the tastiness of the -th dish on day is (where means taking the fractional part). Of course, CYJian is someone who likes to try things, so he will eat a little of every dish.
Now CYJian has queries. Each query asks for the total tastiness gained from day to day . Please help him compute it. Output the answer modulo .
Input Format
The first line contains an integer .
The next lines each contain two integers, representing and for each query.
Output Format
Output lines, each containing a positive integer representing the sum of tastiness.
If the answer can be written as , then you need to find any such that , and output .
1
1 3
499122177
Hint
Sample Explanation
On day 1 the tastiness is . On day 2 the tastiness is . On day 3 the tastiness is . Thus . Since , the answer is .
Constraints
This problem uses bundled testdata.
| Subtask Range | ||
|---|---|---|
Translated by ChatGPT 5