A16259 | Mighty Rock Tower
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Pak Chanek comes up with an idea in the midst of boredom to play a game. The game is a rock tower game. There is a big rock that is used as a base. There are also $N$ small identical rocks that Pak Chanek will use to build a rock tower with a height of $N$ above the base rock.
Initially, there are no small rocks that are located above the base rock. In other words, the height of the tower above the base rock is initially $0$ . In one move, Pak Chanek can place one small rock onto the top of the tower which makes the height of the tower above the base rock increase by $1$ . Each time Pak Chanek place one small rock, the following will happen after the small rock is placed:
- Let's say $x$ is the height of the tower above the base rock right after the small rock is placed.
- There is a probability of $P_x$ percent that the topmost rock falls.
- If $x \geq 2$ and the topmost rock falls, then there is another probability of $P_x$ percent that the $2$ -nd topmost rock also falls.
- If $x \geq 3$ and the $2$ -nd topmost rock falls, then there is another probability of $P_x$ percent that the $3$ -rd topmost rock also falls.
- If $x \geq 4$ and the $3$ -rd topmost rock falls, then there is another probability of $P_x$ percent that the $4$ -th topmost rock also falls.
- And so on.
If the tower successfully reaches a height of $N$ without any rocks falling after that, then the game is ended.
If given an integer array $[P_1, P_2, \ldots, P_N]$ , what is the expected value of the number of moves that Pak Chanek needs to do to end the game? It can be proven that the expected value can be represented as an simple fraction $\frac{P}{Q}$ where $Q$ is coprime to $998\,244\,353$ . Output the value of $P \times Q^{-1}$ modulo $998\,244\,353$ .
Initially, there are no small rocks that are located above the base rock. In other words, the height of the tower above the base rock is initially $0$ . In one move, Pak Chanek can place one small rock onto the top of the tower which makes the height of the tower above the base rock increase by $1$ . Each time Pak Chanek place one small rock, the following will happen after the small rock is placed:
- Let's say $x$ is the height of the tower above the base rock right after the small rock is placed.
- There is a probability of $P_x$ percent that the topmost rock falls.
- If $x \geq 2$ and the topmost rock falls, then there is another probability of $P_x$ percent that the $2$ -nd topmost rock also falls.
- If $x \geq 3$ and the $2$ -nd topmost rock falls, then there is another probability of $P_x$ percent that the $3$ -rd topmost rock also falls.
- If $x \geq 4$ and the $3$ -rd topmost rock falls, then there is another probability of $P_x$ percent that the $4$ -th topmost rock also falls.
- And so on.
If the tower successfully reaches a height of $N$ without any rocks falling after that, then the game is ended.
If given an integer array $[P_1, P_2, \ldots, P_N]$ , what is the expected value of the number of moves that Pak Chanek needs to do to end the game? It can be proven that the expected value can be represented as an simple fraction $\frac{P}{Q}$ where $Q$ is coprime to $998\,244\,353$ . Output the value of $P \times Q^{-1}$ modulo $998\,244\,353$ .
输入格式
The first line contains a single integer $N$ ( $1 \leq N \leq 2\cdot10^5$ ) — the required height of the rock tower.
The second line contains $N$ integers $P_1, P_2, P_3, \ldots, P_N$ ( $0 \leq P_i \leq 99$ ).
The second line contains $N$ integers $P_1, P_2, P_3, \ldots, P_N$ ( $0 \leq P_i \leq 99$ ).
输出格式
An integer representing the expected value of the number of moves that Pak Chanek needs to do to end the game, modulo $998\,244\,353$ .
输入输出样例
输入 #1
2 80 50
输出 #1
499122186
输入 #2
3 25 16 20
输出 #2
879786027
In the first example, the expected value of the number of moves that Pak Chanek needs to do to end the game is $\frac{19}{2}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted