#P9148. 除法题
除法题
Problem Description
Given a set of size , all elements are guaranteed to be distinct and are all positive integers.
If we pick three elements from it in order, then there are different ways to choose.
Now for one choice , define its weight as $\Bigl\lfloor\dfrac{a}{b}\Bigr\rfloor\Bigl\lfloor\dfrac{a}{c}\Bigr\rfloor\Bigl\lfloor\dfrac{b}{c}\Bigr\rfloor$.
You need to compute the sum of weights over all choices. You only need to output this sum modulo .
Note: denotes the greatest integer not greater than . For example, and .
Input Format
The first line contains a positive integer , the length of the sequence.
The second line contains positive integers . Each number describes one element of the set , and all these numbers are distinct.
Output Format
Output one line with one integer, the answer modulo .
4
1 2 3 4
36
6
8 6 4 2 10 15
268
Hint
[Sample Explanation #1]
For sample #1, the only choices with non-zero weight are:
- , with weight .
- , with weight .
- , with weight .
- , with weight .
Therefore, the answer for sample #1 is .
[Constraints]
For of the testdata, .
This problem uses bundled tests.
| Subtask | Special Property | Points | |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | A | ||
| 5 |
Special Property A: it is guaranteed that .
[Hint]
In this problem, most algorithms have small constant factors. Please trust your time complexity.
Translated by ChatGPT 5