#abc310f. F - Make 10 Again
F - Make 10 Again
Score : points
问题陈述
我们有 个骰子。对于每个 ,当投掷第 个骰子时,它会等概率地显示出一个介于 和 (包含两端点)之间的随机整数。
求当同时投掷 个骰子时,满足以下条件的概率对 取模的结果:
存在一种方法,可以选择 个骰子中的某些(可能全部)骰子,使得它们结果的和为 。
如何计算模 下的概率
可以证明所求概率始终是一个有理数。此外,本问题的约束条件保证了如果所求概率表示为不可约分数 的形式,则 不会被 整除。
这里存在一个唯一的整数 ,满足 。请报告这个 值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have dice. For each , when the -th die is thrown, it shows a random integer between and , inclusive, with equal probability.
Find the probability, modulo , that the following condition is satisfied when the dice are thrown simultaneously.
There is a way to choose some (possibly all) of the dice so that the sum of their results is .
How to find a probability modulo
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 , then is not divisible by .
Here, there is a unique integer such that . Report this .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
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 , , , and , respectively, these results satisfy the condition. In fact, if the second and fourth dice are chosen, the sum of their results is . Alternatively, if the first, third, and fourth dice are chosen, the sum of their results is .
On the other hand, if the first, second, third, and fourth dice show , , , and , respectively, there is no way to choose some of them so that the sum of their results is , so the condition is not satisfied.
In this sample input, the probability of the results of the dice satisfying the condition is . Thus, print this value modulo , that is, .
Sample Input 2
7
1 10 100 1000 10000 100000 1000000
Sample Output 2
996117877
update @ 2024/3/10 08:49:06