#P9148. 除法题

    ID: 10172 远端评测题 5000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学数论洛谷原创O2优化组合数学前缀和洛谷月赛

除法题

Problem Description

Given a set aa of size nn, all elements are guaranteed to be distinct and are all positive integers.

If we pick three elements a,b,ca, b, c from it in order, then there are n(n1)(n2)n \cdot (n-1) \cdot (n-2) different ways to choose.

Now for one choice (a,b,c)(a,b,c), 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 2322^{32}.

Note: a\lfloor a\rfloor denotes the greatest integer not greater than aa. For example, 2.4=2\lfloor 2.4\rfloor=2 and 5=5\lfloor 5\rfloor=5.

Input Format

The first line contains a positive integer nn, the length of the sequence.

The second line contains nn positive integers a1,a2,,ana_1, a_2, \ldots, a_n. Each number describes one element of the set aa, and all these numbers are distinct.

Output Format

Output one line with one integer, the answer modulo 2322^{32}.

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:

  • (3,2,1)(3,2,1), with weight 66.
  • (4,2,1)(4,2,1), with weight 1616.
  • (4,3,1)(4,3,1), with weight 1212.
  • (4,3,2)(4,3,2), with weight 22.

Therefore, the answer for sample #1 is 6+16+12+2=366+16+12+2=36.


[Constraints]

For 100%100\% of the testdata, 1n,ai50001 \le n, a_i \le 5000.

This problem uses bundled tests.

Subtask nn Special Property Points
1 =3=3 1010
2 300\le 300 2020
3 2000\le 2000
4 A
5 3030

Special Property A: it is guaranteed that ai=ia_i=i.


[Hint]

In this problem, most algorithms have small constant factors. Please trust your time complexity.

Translated by ChatGPT 5