#P5493. 质数前缀统计
质数前缀统计
Description
Let be the sum of the -th powers of all primes not exceeding .
Given , compute the value of the following expression:
$$\sum_{i=1}^{\lfloor\sqrt{N}\rfloor} i^2 S \!\left( \left\lfloor \frac{N}{i} \right\rfloor \right)$$All results are taken modulo the given prime .
Input Format
One line contains three integers , separated by spaces.
Output Format
Output one integer on one line, representing the computed result.
10 3 1000000007
1458
100000 0 1000000007
941229402
100000 10 1000000007
446053671
Hint
Sample explanation:
$S \!\left( \left\lfloor \frac{N}{1} \right\rfloor \right)\! = S(10) = 2^3 + 3^3 + 5^3 + 7^3 = 503$.
$S \!\left( \left\lfloor \frac{N}{2} \right\rfloor \right)\! = S(5) = 2^3 + 3^3 + 5^3 = 160$.
$S \!\left( \left\lfloor \frac{N}{3} \right\rfloor \right)\! = S(3) = 2^3 + 3^3 = 35$.
$1^2 S \!\left( \left\lfloor \frac{N}{1} \right\rfloor \right)\! + 2^2 S \!\left( \left\lfloor \frac{N}{2} \right\rfloor \right)\! + 3^2 S \!\left( \left\lfloor \frac{N}{3} \right\rfloor \right)\! = 503 + 640 + 315 = 1458$.
Constraints
| Test Point ID | Time Limit | ||
|---|---|---|---|
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号