CF1349D.Slime and Biscuits
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Slime and his n friends are at a party. Slime has designed a game for his friends to play.
At the beginning of the game, the i -th player has ai biscuits. At each second, Slime will choose a biscuit randomly uniformly among all a1+a2+…+an biscuits, and the owner of this biscuit will give it to a random uniform player among n−1 players except himself. The game stops when one person will have all the biscuits.
As the host of the party, Slime wants to know the expected value of the time that the game will last, to hold the next activity on time.
For convenience, as the answer can be represented as a rational number qp for coprime p and q , you need to find the value of (p⋅q−1)mod998244353 . You can prove that qmod998244353=0 .
输入格式
The first line contains one integer n (2≤n≤100000) : the number of people playing the game.
The second line contains n non-negative integers a1,a2,…,an (1≤a1+a2+⋯+an≤300000) , where ai represents the number of biscuits the i -th person own at the beginning.
输出格式
Print one integer: the expected value of the time that the game will last, modulo 998244353 .
输入输出样例
输入#1
2 1 1
输出#1
1
输入#2
2 1 2
输出#2
3
输入#3
5 0 0 0 0 35
输出#3
0
输入#4
5 8 4 2 0 1
输出#4
801604029
说明/提示
For the first example, in the first second, the probability that player 1 will give the player 2 a biscuit is 21 , and the probability that player 2 will give the player 1 a biscuit is 21 . But anyway, the game will stop after exactly 1 second because only one player will occupy all biscuits after 1 second, so the answer is 1 .