P6858 Deep-Sea Girl and Pufferfish

Background

Amazing John had a dream that in his previous previous life, he was a girl. She jumped into the ocean of OI ~~Hearthstone~~ and became the [Deep-Sea Girl](https://music.163.com/#/song?id=22677451), maintaining order in the ocean. One day, the ocean was invaded by a school of pufferfish. To protect the safety of the deep sea, Amazing John fought the pufferfish together with the experts for $9$ days and $9$ nights, but the number of fish did not decrease. ![FGNB](https://cdn.luogu.com.cn/upload/image_hosting/7r0sort3.png)

Description

After a long battle, Amazing John found a way to defeat the pufferfish: There are $n$ “pufferfish” with “Divine Shield” and $m$ pufferfish without Divine Shield. Each time, with equal probability, you deal “Poison” damage to one surviving pufferfish. Now Amazing John wants to know: what is the expected number of times you need to deal damage to kill all the pufferfish? Output the answer modulo $998244353$. “Divine Shield”: When a pufferfish with Divine Shield takes damage, it is immune to this instance of damage. After preventing the damage, the Divine Shield is destroyed. “Pufferfish”: After a pufferfish’s Divine Shield is destroyed, it grants Divine Shield to all other pufferfish that are not dead and do not have Divine Shield. “Poison”: Immediately kills a pufferfish without Divine Shield.

Input Format

The input consists of one line containing two non-negative integers $n,m$, meaning there are $n$ pufferfish with Divine Shield and $m$ pufferfish without Divine Shield.

Output Format

Output one line containing one non-negative integer $s$, the expected number of damage instances modulo $998244353$. Specifically, the answer can always be written as $\frac{p}{q}(p,q\in \mathbb{N},q\neq 0)$, and you need to output $p×q^{-1}$ modulo $998244353$.

Explanation/Hint

This problem has $20$ test points, numbered from $1$ to $20$. For a subtask, you can get the score of that subtask only if you pass all the test points in it. |Subtask|Test Points|Constraints|Score| -|-|-|-| |$1$|$1\sim3$|$n,m \le 5 \times 10^3$|$15$| |$2$|$4\sim5$|$n \le 10^6$,$m=0$|$10$| |$3$|$6\sim10$|$n,m \le 10^6$|$25$| |$4$|$11\sim14$|$n \le 10^{14}$,$m=0$|$20$| |$5$|$15\sim20$|$n \le 10^{14}$,$m\le 10^6$|$30$| The fraction form $\frac{p}{q}$ must satisfy $(p,q\in \mathbb{N},998244353\nmid q)$. ~~I will secretly support you, but do not tell anyone else——Bob.~~ Translated by ChatGPT 5