Gachapon
Time limit5sMemory limit512 MB
Given item frequencies and per-level round counts, compute for each star count the expected number of such items in a legal top-level rolling, times its legality probability, modulo 998244353.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Probability, Math
- Solved
- No attempts yet
Problem
According to Wikipedia, "a gacha game is a video game that implements the gacha (toy vending machine) mechanic". Similar to loot boxes, gacha games lead players to spend in-game currency to receive a random virtual item.
One such game is Step-up Gacha, where the chance of rolling a rare item rises each time the player rolls. For example, Genshin Impact guarantees that a player can always draw a four-star item or character within any ten consecutive rolls.
Abstracting these rolling rules helps. Consider a game with -star, -star, , -star items. The probability of drawing an -star item in a single roll is . A single draw is a level rolling, and a level rolling consists of exactly rounds of level rollings. The highest level of a rolling is .
A level rolling is legal if it ensures the following:
- at least one item with at least stars is drawn,
- for all level rollings it contains, at least one item with at least stars is drawn,
- and so on, down to each level rolling (a single draw), for which at least one item with at least stars is drawn trivially.
Let be the expected number of -star items drawn from a legal -level rolling, and let be the probability that an -level rolling is legal. Find the values of and . To avoid huge numbers and divisions by zero, for every , output only the value .
Input
The first line contains two integers and : the maximum number of stars and the highest level of a rolling ().
The second line contains integers : the frequencies of rolling items with stars ().
The third line contains integers : the number of previous level rollings in a rolling of level ().
Output
Output lines. The -th line should contain a single integer: the value of .
Hint
In the first example, the answers in rational form are: , , .