#abc310f. F - Make 10 Again

F - Make 10 Again

Score : 500500 points

问题陈述

我们有 NN 个骰子。对于每个 i=1,2,,Ni = 1, 2, \ldots, N,当投掷第 ii 个骰子时,它会等概率地显示出一个介于 11AiA_i(包含两端点)之间的随机整数。

求当同时投掷 NN 个骰子时,满足以下条件的概率对 998244353998244353 取模的结果:

存在一种方法,可以选择 NN 个骰子中的某些(可能全部)骰子,使得它们结果的和为 1010

如何计算模 998244353998244353 下的概率

可以证明所求概率始终是一个有理数。此外,本问题的约束条件保证了如果所求概率表示为不可约分数 yx\frac{y}{x} 的形式,则 xx 不会被 998244353998244353 整除。

这里存在一个唯一的整数 zz,满足 xzy(mod998244353)xz \equiv y \pmod{998244353}。请报告这个 zz 值。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have NN dice. For each i=1,2,,Ni = 1, 2, \ldots, N, when the ii-th die is thrown, it shows a random integer between 11 and AiA_i, inclusive, with equal probability.

Find the probability, modulo 998244353998244353, that the following condition is satisfied when the NN dice are thrown simultaneously.

There is a way to choose some (possibly all) of the NN dice so that the sum of their results is 1010.

How to find a probability modulo 998244353998244353

It can be proved that the sought probability is always a rational number. Additionally, the constraints of this problem guarantee that if the sought probability is represented as an irreducible fraction yx\frac{y}{x}, then xx is not divisible by 998244353998244353.

Here, there is a unique integer zz such that xzy(mod998244353)xz \equiv y \pmod{998244353}. Report this zz.

Constraints

  • 1N1001 \leq N \leq 100
  • 1Ai1061 \leq A_i \leq 10^6
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots ANA_N

Output

Print the answer.

Sample Input 1

4
1 7 2 9

Sample Output 1

942786334

For instance, if the first, second, third, and fourth dice show 11, 33, 22, and 77, respectively, these results satisfy the condition. In fact, if the second and fourth dice are chosen, the sum of their results is 3+7=103 + 7 = 10. Alternatively, if the first, third, and fourth dice are chosen, the sum of their results is 1+2+7=101 + 2 + 7 = 10.

On the other hand, if the first, second, third, and fourth dice show 11, 66, 11, and 55, respectively, there is no way to choose some of them so that the sum of their results is 1010, so the condition is not satisfied.

In this sample input, the probability of the results of the NN dice satisfying the condition is 1118\frac{11}{18}. Thus, print this value modulo 998244353998244353, that is, 942786334942786334.

Sample Input 2

7
1 10 100 1000 10000 100000 1000000

Sample Output 2

996117877

update @ 2024/3/10 08:49:06