#P17239. 『STA - R10』雨落玫瑰
『STA - R10』雨落玫瑰
Problem Description
This is a multi-test problem. Each test gives positive integers . You need to compute the following value:
$$\sum_{x=1}^n\left[\left\lfloor\dfrac{ax+b}c\right\rfloor\le\left\lfloor\dfrac{dx+e}f\right\rfloor\right]\cdot\left\lfloor\dfrac{ax+b}c\right\rfloor$$Take the answer modulo .
Input Format
The first line contains a positive integer , the number of test cases.
The next lines each contain seven positive integers , describing one query.
Output Format
Output lines. Each line is the answer for one query, modulo .
3
1 2 3 4 5 6 7
7 6 5 4 3 2 1
300 500 700 301 499 720 1000
12
2
477
Hint
This problem uses bundled tests. Subtasks are as follows:
- Subtask 1 (10 pts): .
- Subtask 2 (20 pts): .
- Subtask 3 (70 pts): No special constraints.
Constraints for all testdata: , .
Note: The input file is large, so please pay attention to I/O efficiency.
Translated by ChatGPT 5