#P6858. 深海少女与胖头鱼

深海少女与胖头鱼

Description

After a long battle, Amazing John found a way to defeat the pufferfish:

There are nn “pufferfish” with “Divine Shield” and mm 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 998244353998244353.

“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,mn,m, meaning there are nn pufferfish with Divine Shield and mm pufferfish without Divine Shield.

Output Format

Output one line containing one non-negative integer ss, the expected number of damage instances modulo 998244353998244353.

Specifically, the answer can always be written as pq(p,qN,q0)\frac{p}{q}(p,q\in \mathbb{N},q\neq 0), and you need to output p×q1p×q^{-1} modulo 998244353998244353.

2 1
8
10 10
499122389
10 0
65
2 0
5

Hint

This problem has 2020 test points, numbered from 11 to 2020. 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
11 131\sim3 n,m5×103n,m \le 5 \times 10^3 1515
22 454\sim5 n106n \le 10^6m=0m=0 1010
33 6106\sim10 n,m106n,m \le 10^6 2525
44 111411\sim14 n1014n \le 10^{14}m=0m=0 2020
55 152015\sim20 n1014n \le 10^{14}m106m\le 10^6 3030

The fraction form pq\frac{p}{q} must satisfy (p,qN,998244353q)(p,q\in \mathbb{N},998244353\nmid q).

I will secretly support you, but do not tell anyone else——Bob.

Translated by ChatGPT 5