P29178 [洛谷] Deep Sea Girl and Fathead Fish
提高
题目描述

Problem Background

Amazing John had a dream where he was a girl from his past life.

She jumped into the ocean of OI, becoming a "Deep Sea Girl," maintaining the order of the ocean.

One day, the ocean was invaded by a swarm of fathead fish. To protect the deep sea, Amazing John and the experts fought the fish for 9 days and 9 nights, but the number of fish did not decrease.

FGNB

Problem Description

After a long battle, Amazing John discovered a method to defeat the fathead fish:

There are $n$ "fathead fish" with "Divine Shield" and $m$ fathead fish without a shield. Each time, damage is inflicted with "Deadly Poison" on a living fathead fish with equal probability.

Now, Amazing John wants to know the expected number of damage infliction needed to kill all the fathead fish.

The answer should be modulo $998244353$.

"Divine Shield": When a fathead fish with a shield takes damage, it is immune to the damage. After immunity, the shield is broken.

"Fathead Fish": After a fathead fish's shield is broken, it grants a shield to all other non-dead, shieldless fathead fish.

"Deadly Poison": Instantly kills a fathead fish without a shield.

Input Format

The input consists of a single line containing two non-negative integers $n$ and $m$, representing the number of fathead fish with a shield and the number of fathead fish without a shield, respectively.

Output Format

The output consists of a single line with a non-negative integer $s$, representing the expected number of damage infliction modulo $998244353$.

Specifically, the answer can always be expressed in the form $\frac{p}{q}$ where $p, q \in \mathbb{N}$ and $q \neq 0$. You need to output the value of $p \times q^{-1}$ under modulo $998244353$.

Sample Input and Output

Sample Input #1

2 1

Sample Output #1

8

Sample Input #2

10 10

Sample Output #2

499122389

Sample Input #3

10 0

Sample Output #3

65

Sample Input #4

2 0

Sample Output #4

5

Notes

There are 20 data points, numbered from 1 to 20. For a subtask, you must pass all its data points to earn the score.

Subtask Data Points Data Range Score
1 1-3 $n, m \le 5 \times 10^3$ 15
2 4-5 $n \le 10^6$, $m = 0$ 10
3 6-10 $n, m \le 10^6$ 25
4 11-14 $n \le 10^{14}$, $m = 0$ 20
5 15-20 $n \le 10^{14}$, $m \le 10^6$ 30

The form of the answer $\frac{p}{q}$ always satisfies $(p, q \in \mathbb{N}, 998244353 \nmid q)$.

I will secretly support you, don't tell anyone - Bob.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 1
样例输出
8