#P3312. [SDOI2014] 数表
[SDOI2014] 数表
Description
There is an table of numbers. The value at row and column (, ) equals the sum of all natural numbers that divide both and . Given , compute the sum of all numbers in the table that are not greater than .
Input Format
The input contains multiple test cases.
The first line contains an integer , the number of test cases.
Each of the next lines contains three integers , , (), describing one test case.
Output Format
For each test case, output one line with a single integer: the answer modulo .
2
4 4 3
10 10 5
20
148
Hint
Constraints and Conventions
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号