問題一覧 > 通常問題

No.2045 Two Reflections

レベル : / AI推定難易度 : 1850 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 61
作問者 : 👑 箱星 / テスター : 👑 hitonanode Shirotsume
お気に入りにしたユーザー ProblemId : 7780 / 自分の提出
問題文最終更新日: 2022-08-20 00:23:23
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 357 (順位表) の他の問題:

Problem Statement

You are given $3$ positive integers $N,p,q$. A sequence $A$ of length $N$ initially satisfies $A_i=i \ (1\le i\le N)$.

Consider the following $2$ types of operations.

  • Operation $1$: Reverse the first $p$ terms. That is, replace $A_1,A_2,\ldots,A_p$ with $A_p,A_{p-1},\ldots,A_1$.
  • Operation $2$: Reverse the last $q$ terms. That is, replace $A_{N-q+1},\ldots,A_{N-1},A_N$ with $A_N,A_{N-1},\ldots,A_{N-q+1}$.

How many different sequences can be obtained by performing the operations $0$ or more times in any order? Find the answer modulo $998244353$.

Constraints

  • $1\le N\le 10^5$
  • $1\le p, q\le N$
  • All input values are integers.

Input

$N$ $p$ $q$

Output

Find the number of sequences that can be obtained, and print it modulo $998244353$.

Sample

Sample 1
Input
4 2 2
Output
4

Operation $1$ replaces $A_1,A_2,A_3,A_4$ with $A_2,A_1,A_3,A_4$, and operation $2$ replaces $A_1,A_2,A_3,A_4$ with $A_1,A_2,A_4,A_3$. The sequences that can be obtained are the following:

  • $1,2,3,4$
  • $1,2,4,3$
  • $2,1,3,4$
  • $2,1,4,3$

for a total of $4$ sequences.

Sample 2
Input
10 4 7
Output
12

Sample 3
Input
100000 99999 99998
Output
451444810

Print the answer modulo $998244353$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。