#P6858. 深海少女与胖头鱼
深海少女与胖头鱼
Description
After a long battle, Amazing John found a way to defeat the pufferfish:
There are “pufferfish” with “Divine Shield” and 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 .
“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 , meaning there are pufferfish with Divine Shield and pufferfish without Divine Shield.
Output Format
Output one line containing one non-negative integer , the expected number of damage instances modulo .
Specifically, the answer can always be written as , and you need to output modulo .
2 1
8
10 10
499122389
10 0
65
2 0
5
Hint
This problem has test points, numbered from to . 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 |
|---|---|---|---|
| , | |||
| , | |||
| , |
The fraction form must satisfy .
I will secretly support you, but do not tell anyone else——Bob.
Translated by ChatGPT 5
京公网安备 11011102002149号