QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 1024 MB 總分: 100

#10709. 随机余数

统计

给定一个包含 $n$ 个随机正整数的序列:$a_1, a_2, \dots, a_n$。你的任务是计算以下和:

$$\sum_{i=1}^{n} \sum_{j=1}^{n} (a_i \bmod a_j)^2$$

输入格式

输入的第一行包含测试用例的数量:$Z$ ($1 \le Z \le 1000$)。接下来是各测试用例的描述。

每个测试用例的第一行包含序列的长度 $n$ ($1 \le n \le 200\,000$)。第二行包含该序列,即 $n$ 个由空格分隔的正整数。每个数都是从范围 $[1, 10^{12}]$ 中均匀伪随机生成的。

所有测试用例的 $n$ 之和不超过 $400\,000$。

输出格式

对于每个测试用例,输出所求的和对 $998244353$ 取模的结果。

样例

输入格式 1

1
2
3 5

输出格式 1

13

说明

$(3 \bmod 3)^2 + (5 \bmod 3)^2 + (3 \bmod 5)^2 + (5 \bmod 5)^2 = 0 + 4 + 9 + 0 = 13$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.