题库练习 Serval and Music Game
← 上一题 下一题 →

A15718 | Serval and Music Game

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Serval loves playing music games. He meets a problem when playing music games, and he leaves it for you to solve.

You are given $n$ positive integers $s_1 < s_2 < \ldots < s_n$ . $f(x)$ is defined as the number of $i$ ( $1\leq i\leq n$ ) that exist non-negative integers $p_i, q_i$ such that:

$$ s_i=p_i\left\lfloor{s_n\over x}\right\rfloor + q_i\left\lceil{s_n\over x}\right\rceil $$

Find out $\sum_{x=1}^{s_n} x\cdot f(x)$ modulo $998\,244\,353$ .

As a reminder, $\lfloor x\rfloor$ denotes the maximal integer that is no greater than $x$ , and $\lceil x\rceil$ denotes the minimal integer that is no less than $x$.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1\leq t\leq 10^4$ ). The description of the test cases follows.

The first line of each test cases contains a single integer $n$ ( $1\leq n\leq 10^6$ ).

The second line of each test case contains $n$ positive integers $s_1,s_2,\ldots,s_n$ ( $1\leq s_1 < s_2 < \ldots < s_n \leq 10^7$ ).

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$ , and the sum of $s_n$ does not exceed $10^7$ .

输出格式

For each test case, print a single integer in a single line — the sum of $x\cdot f(x)$ over all possible $x$ modulo $998\,244\,353$ .

输入输出样例

输入 #1
4
3
1 2 4
4
1 2 7 9
4
344208 591000 4779956 5403429
5
1633 1661 1741 2134 2221
输出 #1
26
158
758737625
12334970
C++ 编辑器
输入
输出