8633: Connectivity of Erd!7;s-Rényi Graph

内存限制:128 MB 时间限制:5 S
题面:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Yukikaze is studying the theory of random graphs.

In the probability version of the Erdős-Rényi model, a random graph is constructed by connecting nodes randomly. That is, the random graph G(n,p) is an undirected graph with n vertices, and each edge from the 2n(n1) possible edges is included in the graph with probability pp independently from every other edge.

Now she wonders about the expected number of connected components in G(n,p), modulo a large prime 998244353

输入格式

The first line of the input contains a single integer T (1T100), denoting the number of test cases.

The first line of each test case contains three integers q,a,b(1q1051ab<998244353), denoting the number of queires and the probability p=a/b.

The second line of each test case contains q integers n1,n2,,nq (1ni<5×105 for each 1iq) seperated by spaces, denoting that Yukikaze wants to know the expected number of connected components in G(n_i,p)G(ni,p).

Let N be the sum of the maximum ni of each test case, and Q be the sum of q of all test cases. It's guaranteed that N5×105 and Q105.

输出格式

For each test case, output a single line containing the answers to the queries separated by spaces. You should output the answers modulo 998244353. That is, if the answer is QP, you should output PQ1mod998244353, where Q1 denotes the multiplicative inverse of Qmodulo 998244353. We can prove that the answer can always be expressed in this form.

Don't output any extra spaces at the end of each line.

输入样例 复制

3
1 14 51
4
1 91 98
10
2 114 514
1919 810

输出样例 复制

798850218
132789114
904977379 493892762