当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7162:Equipment Upgrade

题目描述
Little Q is playing an RPG game. In this game, the weapon can be upgraded. Initially, the weapon is at level $0$, and the upper bound of the level is $n$. Assume the current level is $i$ ($0 \leq i < n$), Little Q can pay $c_i$ coins to upgrade the weapon, the next level will be $i+1$ with probability $p_i$, and will be $i-j$ ($1 \leq j \leq i$) with probability $\left(1-p_i\right)\frac{w_j}{\sum_{k=1}^i w_k}$.

Though Little Q is very rich, he is still wondering the expected number of coins for him to upgrade the weapon from level $0$ to level $n$. Please write a program to help him.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 300$), the number of test cases. For each test case:

The first line contains a single integer $n$ ($2 \leq n \leq 100\,000$), denoting the upper bound of the level.

The $i$-th ($1\leq i\leq n$) of the following $n$ lines contains two integers $P_{i-1}$ and $c_{i-1}$ ($1 \leq P_{i-1},c_{i-1} \leq 100$), describing the success probability and the cost for level $i-1$. Here $p_{i-1}=\frac{P_{i-1}}{100}$. It is guaranteed that $P_0=100$.

The next line contains $n-1$ integers $w_1,w_2,\dots,w_{n-1}$ ($1\leq w_i\leq 100$).

It is guaranteed that the sum of all $n$ is at most $500\,000$.
输出解释
For each test case, output a single line containing an integer, denoting the expected number of coins to level $n$.

More precisely, if the answer is $\frac{p}{q}$, you should output the minimum non-negative integer $r$ such that $q \cdot r \equiv p \pmod{998\,244\,353}$. You may safely assume that such $r$ always exists in all test cases.
输入样例
2
2
100 1
50 5
1
3
100 1
70 2
50 3
2 3
输出样例
12
228170152

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7162

最后修改于 2022-09-15T06:17:07+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/10000MS(Java/Others) 524288/524288K(Java/Others)