| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB (추가 메모리 없음) | 135 | 65 | 60 | 53.571% |
Two players A and B are playing a game called mukjjippa.
The game consists of several turns.
At the $i$-th turn ($1\le i\le n$):
Note that there is no attacker for the first turn.
If the game does not end until the beginning of the $(n+1)$-th turn, nobody is a winner.
The probability distribution of each choice is given. All choices are independent.
Find the probability that A wins.
The first line contains an integer $n$.
The $i$-th of the next $n$ lines contains three integers $r_i$, $s_i$, and $p_i$. This means that the probabilities that $X_i$ is $\mathrm R$, $\mathrm S$, and $\mathrm P$ are $\frac{r_i}{r_i+s_i+p_i}$, $\frac{s_i}{r_i+s_i+p_i}$, and $\frac{p_i}{r_i+s_i+p_i}$, respectively.
The $i$-th of the next $n$ lines contains three integers $r_i'$, $s_i'$, and $p_i'$. This means that the probabilities that $Y_i$ is $\mathrm R$, $\mathrm S$, and $\mathrm P$ are $\frac{r_i'}{r_i'+s_i'+p_i'}$, $\frac{s_i'}{r_i'+s_i'+p_i'}$, and $\frac{p_i'}{r_i'+s_i'+p_i'}$, respectively.
Let $\frac{x}{y}$ be the probability that A wins, where $x$ and $y$ are coprime integers, and $x\ge 0$ and $y>0$.
Print the integer $z$ such that $yz\equiv x\pmod{998\, 244\, 353}$ and $0\le z<998\, 244\, 353$.
It can be proved that such an integer $z$ always exists and is uniquely determined, under the constraints of this problem.
2 1 0 0 0 1 0 0 1 0 0 1 0
1
2 1 1 1 1 1 1 1 1 1 1 1 1
443664157
University > KAIST > KAIST ICPC Mock Competition > 2024 KAIST 14th ICPC Mock Competition I번