#P6055. [RC-02] GCD
[RC-02] GCD
Description
Given , compute:
$$\sum_{i=1}^N\sum_{j=1}^N\sum_{p=1}^{\lfloor\frac{N}{j}\rfloor}\sum_{q=1}^{\lfloor\frac{N}{j}\rfloor}[\gcd(i,j)=1][\gcd(p,q)=1]$$Output the answer modulo .
is a conditional expression. When the statement inside the brackets is true, its value is , otherwise it is .
Input Format
A single line containing one integer .
Output Format
Output one integer, the required answer modulo .
50
104527
200
6664993
500000
835964450
10000000
503290049
100000000
712748411
1000000000
845640070
Hint
For all data, it is guaranteed that . The time limit for all test points is , and the memory limit is .
| Test Point ID | |
|---|---|
This problem could actually have been made into multiple test cases in one input. But the kind problem setter decided to use only one test case, to give you more chances to get partial points.
The idea came from @Fee_cle6418. The statement, official solution, and testdata come from @FangZeLi.
Translated by ChatGPT 5
京公网安备 11011102002149号