题目描述
Problem Description
Given \( n, m \) and \( n \) integers \( a_i \) (\( 1 \le i \le n \)).
Calculate:
\[ \sum_{i=1}^{n} \sum_{j=1}^{n} \left\lfloor \frac{m}{a_i a_j} \right\rfloor \]
Output the result modulo \( 998244353 \).
Input Format
The first line contains two integers \( n \) and \( m \).
The second line contains \( n \) integers \( a_1, a_2, \ldots, a_n \).
Output Format
Output a single integer representing the result modulo \( 998244353 \).
Sample Input and Output
Sample Input #1
5 30
2 2 8 4 2
Sample Output #1
88
Sample Input #2
10 5035239199
4853 53137 86933 4465 13588 11899 49877 16317 43326 52183
Sample Output #2
2715
Notes
Sample Explanation
The contributions in the first sample are as follows:
- \((a_1, a_1): \left\lfloor \frac{30}{2 \times 2} \right\rfloor = 7\)
- \((a_1, a_2), (a_2, a_1): \left\lfloor \frac{30}{2 \times 2} \right\rfloor \times 2 = 14\)
- \((a_1, a_3), (a_3, a_1): \left\lfloor \frac{30}{2 \times 8} \right\rfloor \times 2 = 2\)
- \((a_1, a_4), (a_4, a_1): \left\lfloor \frac{30}{2 \times 4} \right\rfloor \times 2 = 6\)
- \((a_1, a_5), (a_5, a_1): \left\lfloor \frac{30}{2 \times 2} \right\rfloor \times 2 = 14\)
- \((a_2, a_2): \left\lfloor \frac{30}{2 \times 2} \right\rfloor = 7\)
- \((a_2, a_3), (a_3, a_2): \left\lfloor \frac{30}{2 \times 8} \right\rfloor \times 2 = 2\)
- \((a_2, a_4), (a_4, a_2): \left\lfloor \frac{30}{2 \times 4} \right\rfloor \times 2 = 6\)
- \((a_2, a_5), (a_5, a_2): \left\lfloor \frac{30}{2 \times 2} \right\rfloor \times 2 = 14\)
- \((a_3, a_5), (a_5, a_3): \left\lfloor \frac{30}{2 \times 8} \right\rfloor \times 2 = 2\)
- \((a_4, a_4): \left\lfloor \frac{30}{4 \times 4} \right\rfloor = 1\)
- \((a_4, a_5), (a_5, a_4): \left\lfloor \frac{30}{2 \times 4} \right\rfloor \times 2 = 6\)
- \((a_5, a_5): \left\lfloor \frac{30}{2 \times 2} \right\rfloor = 7\)
Summing these contributions: \( 7 + 14 + 2 + 6 + 14 + 7 + 2 + 6 + 14 + 2 + 1 + 6 + 7 = 88 \).
Data Range
| Subtask Number | \( n \) | \( m \) | \( a_i \) | Score | Special Property |
|---|---|---|---|---|---|
| 0 | \(\le 10^2\) | \(\le 10^6\) | \(\le 10^5\) | 10 | - |
| 1 | \(\le 10^4\) | \(\le 10^{10}\) | \(\le 10^9\) | 10 | - |
| 2 | \(\le 10^6\) | \(\le 10^{10}\) | \(\le 10^4\) | 10 | - |
| 3 | \(\le 10^6\) | \(\le 10^8\) | \(\le 10^9\) | 20 | - |
| 4 | \(\le 10^6\) | \(\le 10^{10}\) | \(\le 10^9\) | 20 | A |
| 5 | \(\le 10^6\) | \(\le 10^{10}\) | \(\le 10^9\) | 30 | - |
Special Property A: \(\sum_{i=1}^{n} a_i \le 10^7\).
For \( 100\% \) of the data, \( 1 \le n \le 10^6 \), \( 1 \le a_i \le 10^9 \), \(\sum_{i=1}^{n} a_i \le 10^9 \), \( 1 \le m \le 10^{10} \).
Special Note: This problem uses subtask-based scoring. You must pass all test cases in a subtask to earn the points for that subtask.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分