luogu#P9621. 下次再见

下次再见

Background

In the season that has passed, the lost treasure.

Is a precious jigsaw puzzle missing one corner.

Just like how white snow gently piles up on the streets.

Let it also fill all the blank spaces in the memory album.

Problem Description

There is a piece of music made up of nn circles. The player will uniformly randomly choose a starting position from 1n1 \sim n, then click that position and all circles after it in order to finish playing the piece.

For each circle, the click accuracy has four possible judgments: GREAT,OK,MEH,MISS\texttt{GREAT,OK,MEH,MISS}.

There is a mechanism: after KK consecutive MISS\texttt{MISS} judgments, the player will be forced to exit the game; otherwise, the player will keep playing until all circles have been clicked.

Now you are given, for each circle, the probability that the player gets each judgment. For the ii-th circle, the probabilities of GREAT\texttt{GREAT}, OK\texttt{OK}, MEH\texttt{MEH}, and MISS\texttt{MISS} are $P_{i,0}/100,\ P_{i,1}/100,\ P_{i,2}/100,\ P_{i,3}/100$, respectively. It is guaranteed that Pi,0+Pi,1+Pi,2+Pi,3=100P_{i,0}+P_{i,1}+P_{i,2}+P_{i,3}=100.

The score is a measure of the whole performance. It is computed as follows: suppose in the whole performance there are aa times GREAT\texttt{GREAT}, bb times OK\texttt{OK}, cc times MEH\texttt{MEH}, and dd times MISS\texttt{MISS}, then the score is 300a+100b+50c300a+100b+50c.

You need to answer the expected value of the player's score.

Note: If the player is forced to exit the game, then when computing the score, the whole performance includes all clicks from the starting click up to and including the click that produced the last MISS\texttt{MISS} judgment.

For some test points with larger data sizes, in order to reduce the amount of input/output interaction, we use a different input method. You need to include the data generator provided in the attached file in your C++ code. It is recommended to browse the function names provided in the generator before reading the following content, as this can help you better understand the input format.

Input Format

The first line contains two integers Type,seedType,seed.

When Type=1Type=1, after reading seedseed you need to call Ge.init(seed) to set the seed of the data generator. Otherwise, you may ignore seedseed.

The second line contains two integers n,Kn,K.

Then there are two cases:

  • Type=0Type=0. The next nn lines each contain 44 integers, representing Pi,0 Pi,1 Pi,2 Pi,3P_{i,0}\ P_{i,1}\ P_{i,2}\ P_{i,3}.

  • Type=1Type=1. There is no further input. After your ii-th call to Ge.get(a,b,c,d), the values of a,b,c,da,b,c,d are Pi,0 Pi,1 Pi,2 Pi,3P_{i,0}\ P_{i,1}\ P_{i,2}\ P_{i,3}, respectively.

Output Format

Output one integer per line, representing the answer mod 998244353\bmod\ 998244353.

Note: It can be proven that the answer can be expressed as p/qp/q. You need to output the result of multiplying pp by the modular inverse of qq modulo 998244353998244353, and then taking it modulo 998244353998244353.

0 0
4 2
10 20 20 50
20 10 20 50
20 20 10 50
20 50 10 20

530317523
0 280114129
5 5
36 23 30 11
0 52 25 23
14 61 23 2
10 41 37 12
0 12 78 10

898420164
1 114
5141 919

800181066

Hint

Test Point ID Constraints Special Property
121\sim 2 n5n\le 5
343\sim 4 n50n\le 50
565\sim 6 n103n\le 10^3
787\sim 8 n105,K103n\le 10^5,K\le 10^3
9109\sim 10 AA
111211\sim 12 BB
131513\sim 15 n,K5×105n,K\le 5\times 10^5
162016\sim 20

AA: It is guaranteed that Pi,3P_{i,3} is the same for all positions.

BB: It is guaranteed that for all positions, Pi,3P_{i,3} equals 00 or equals 100100.


For test points 1151\sim 15, Type=0Type=0; for test points 162016\sim 20, Type=1Type=1.

It is guaranteed that for all data, 0Pi,0/1/2/31000\le P_{i,0/1/2/3}\le 100, 1Kn5×1061\le K\le n\le 5\times 10^6, Type=0/1Type=0/1, 1seed1091\le seed\le 10^9.

Translated by ChatGPT 5