atcoder#AGC060C. [AGC060C] Large Heap
[AGC060C] Large Heap
Score : points
Problem Statement
Consider a permutation of . is said to be heaplike if and only if all of the following conditions are satisfied.
- ()
- ()
You are given integers and . Let and .
Find the probability, modulo , that $P_U for a heaplike permutation chosen uniformly at random.
Definition of probability modulo $998244353$
It can be proved that the sought probability is always rational. Additionally, under the constraints of this problem, when the sought rational number is represented as an irreducible fraction , it can be proved that . Therefore, there is a unique integer such that and . Print this .
Constraints
- All numbers in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
2 1 1
499122177
There are two heaplike permutations: . The probability that $P_2 is .
3 1 2
124780545
4 3 2
260479386
2022 12 25
741532295