#AGC060C. [AGC060C] Large Heap

    ID: 2416 传统题 10000ms 1024MiB 尝试: 1 已通过: 0 难度: 6 上传者: 标签>动态规划,dp组合数学排列组合概率论

[AGC060C] Large Heap

Score : 800800 points

Problem Statement

Consider a permutation P=(P1,P2,,P2N1)P=(P_1,P_2,\cdots,P_{2^N-1}) of (1,2,,2N1)(1,2,\cdots,2^N-1). PP is said to be heaplike if and only if all of the following conditions are satisfied.

  • Pi<P2iP_i < P_{2i} (1i2N111 \leq i \leq 2^{N-1}-1)
  • Pi<P2i+1P_i < P_{2i+1} (1i2N111 \leq i \leq 2^{N-1}-1)

You are given integers AA and BB. Let U=2AU=2^A and V=2B+11V=2^{B+1}-1.

Find the probability, modulo 998244353998244353, 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 PQ\frac{P}{Q}, it can be proved that Q0(mod998244353)Q \neq 0 \pmod{998244353}. Therefore, there is a unique integer RR such that R×QP(mod998244353)R \times Q \equiv P \pmod{998244353} and 0R<9982443530 \leq R \lt 998244353. Print this RR.

Constraints

  • 2N50002 \leq N \leq 5000
  • 1A,BN11 \leq A,B \leq N-1
  • All numbers in the input are integers.

Input

The input is given from Standard Input in the following format:

NN AA BB

Output

Print the answer.

2 1 1
499122177

There are two heaplike permutations: P=(1,2,3),(1,3,2)P=(1,2,3),(1,3,2). The probability that $P_2 is 1/21/2.

3 1 2
124780545
4 3 2
260479386
2022 12 25
741532295