7570: Expectation

内存限制:512 MB 时间限制:10 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Notice:Don't output extra spaces at the end of one line.

There are (2n+1) distinct positions on the number line, x1,x2,....x2n+1 in the strictly increasing order. each position with odd index is a hole and each postition with even index is a ball.

Koishi will play a game consisting of n rounds, in each round:

1.Koishi selects a ball that isn't in holes at random.

2.then select the direction,left or right at random.

3.then the chosen ball starts rolling in that chosen direction, until it falls into an empty hole(the hole with no ball falling into it before)

Koishi is interested in the sum of distances of balls rolling. What is the expected value of the sum? modulo 998244353

输入格式

First line contains an integer T(1≤T≤2000), number of test cases.

In each test cases, the first line contains an integer n(1≤n≤3000). The second line contains (2n+1) integers in a single line representing x1,x2,...x2n+1

−109≤x1<x2,...,<x2n+1≤109

输出格式

T lines, each with a non-negative integer representing the answer.

输入样例 复制

3
1
1 2 3
3
1 2 3 4 5 6 7
10
0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210

输出样例 复制

1
332748122
969129126