CF1866M.Mighty Rock Tower

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 NN small identical rocks that Pak Chanek will use to build a rock tower with a height of NN 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 00. 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 11. Each time Pak Chanek place one small rock, the following will happen after the small rock is placed:

  • Let's say xx is the height of the tower above the base rock right after the small rock is placed.
  • There is a probability of PxP_x percent that the topmost rock falls.
  • If x≥2x \geq 2 and the topmost rock falls, then there is another probability of PxP_x percent that the 22-nd topmost rock also falls.
  • If x≥3x \geq 3 and the 22-nd topmost rock falls, then there is another probability of PxP_x percent that the 33-rd topmost rock also falls.
  • If x≥4x \geq 4 and the 33-rd topmost rock falls, then there is another probability of PxP_x percent that the 44-th topmost rock also falls.
  • And so on.

If the tower successfully reaches a height of NN without any rocks falling after that, then the game is ended.

If given an integer array [P1,P2,…,PN][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 PQ\frac{P}{Q} where QQ is coprime to 998 244 353998\,244\,353. Output the value of P×Q−1P \times Q^{-1} modulo 998 244 353998\,244\,353.

帕克·查内克在百无聊赖之际想出了一个游戏点子。这个游戏叫做“石塔游戏”。游戏中有一块大石头,作为底座;此外还有 NN 块完全相同的小石头,帕克·查内克将用它们在底座之上搭建一座高度为 NN 的石塔。

初始时,底座上方没有任何小石头,即石塔在底座之上的高度为 00。每一步操作中,帕克·查内克可将一块小石头放置在石塔顶端,使石塔在底座之上的高度增加 11。每次放置一块小石头后,将发生如下事件:

  • 设 xx 为该小石头刚被放置完毕后,石塔在底座之上的高度;
  • 此时最顶端的石头有 PxP_x 的概率掉落;
  • 若 x≥2x \geq 2 且最顶端的石头掉落,则第二顶端的石头也有 PxP_x 的概率掉落;
  • 若 x≥3x \geq 3 且第二顶端的石头掉落,则第三顶端的石头也有 PxP_x 的概率掉落;
  • 若 x≥4x \geq 4 且第三顶端的石头掉落,则第四顶端的石头也有 PxP_x 的概率掉落;
  • 依此类推。

若石塔成功达到高度 NN,且此后再无任何石头掉落,则游戏结束。

现给定一个整数数组 [P1,P2,…,PN][P_1, P_2, \ldots, P_N],问:帕克·查内克结束游戏所需的操作步数的期望值是多少?可以证明该期望值可表示为最简分数 PQ\frac{P}{Q},其中 QQ 与 998 244 353998\,244\,353 互质。请输出 P×Q−1 mod 998 244 353P \times Q^{-1} \bmod 998\,244\,353 的值。

输入格式

The first line contains a single integer NN (1≤N≤2⋅1051 \leq N \leq 2\cdot10^5) — the required height of the rock tower.

The second line contains NN integers P1,P2,P3,…,PNP_1, P_2, P_3, \ldots, P_N (0≤Pi≤990 \leq P_i \leq 99).

第一行包含一个整数 NN(1≤N≤2⋅1051 \leq N \leq 2\cdot10^5)—— 表示岩石塔所需的高度。

第二行包含 NN 个整数 P1,P2,P3,…,PNP_1, P_2, P_3, \ldots, P_N(0≤Pi≤990 \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 353998\,244\,353.

一个整数,表示 Pak Chanek 为结束游戏所需移动次数的期望值对 998 244 353998\,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 192\frac{19}{2}.

在第一个例子中,Pak Chanek 为结束游戏所需移动次数的期望值为 192\frac{19}{2}。

输入解题思路,AI测评打分。不知道怎么写?

首页