CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!)
G
Bessie and Cards
Codeforces
2800
原题
← FH →
翻译中…

Bessie has recently started playing a famous card game. In the game, there is only one deck of cards, consisting of $a$ "draw $0$" cards, $b$ "draw $1$" cards, $c$ "draw $2$" cards, and $5$ special cards. At the start of the game, all cards are in the randomly shuffled deck.

翻译中…

Bessie starts the game by drawing the top $5$ cards of the deck. She may then play "draw $x$" cards from the hand to draw the next $x$ cards from the top of the deck. Note that every card can only be played once, special cards cannot be played, and if Bessie uses a "draw $2$" card when there is only $1$ card remaining in the deck, then she simply draws that remaining card. Bessie wins if she draws all $5$ special cards.

翻译中…

Since Bessie is not very good at math problems, she wants you to find the probability that she wins, given that the deck is shuffled randomly over all $(a + b + c + 5)!$ possible orderings. It can be shown that this answer can always be expressed as a fraction $\frac{p}{q}$ where $p$ and $q$ are coprime integers. Output $p \cdot q^{-1}$ modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

翻译中…

Each test case contains three integers $a$, $b$, and $c$ ($0 \le a, b, c \le 2 \cdot 10^5$) – the number of draw $0$ cards, draw $1$ cards, and draw $2$ cards, respectively.

翻译中…

It is guaranteed that the sum of $a$ over all test cases does not exceed $2 \cdot 10^5$, the sum of $b$ over all test cases does not exceed $2 \cdot 10^5$, and the sum of $c$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output a single integer — the probability that Bessie wins, modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first case, we have $1$ of each type of "draw" card and $5$ special cards. There are $30\,720$ starting decks where Bessie will win by drawing the top $5$ cards and $40\,320$ starting decks in total. Thus, the probability of Bessie winning is $\frac{30\,720}{40\,320} = \frac{16}{21}$.

翻译中…

One example of a winning starting deck is, top to bottom,

翻译中…
  1. "Special",
  2. "Draw $1$",
  3. "Special",
  4. "Special",
  5. "Draw $0$",
  6. "Draw $2$",
  7. "Special",
  8. "Special".
翻译中…

One example of a losing starting deck is:

翻译中…
  1. "Special",
  2. "Draw $1$",
  3. "Special",
  4. "Special",
  5. "Draw $0$",
  6. "Special",
  7. "Special",
  8. "Draw $2$".
翻译中…

样例

Input #1
4
1 1 1
0 0 0
5 3 7
3366 1434 1234
Output #1
903173463
1
35118742
398952013
InputCopy OutputCopy
题目信息
题号
1942G
时间限制
2 s
内存限制
256 MB
标签
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。