A11725 | Bandit Blues
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Japate, while traveling through the forest of Mala, saw $N$ bags of gold lying in a row. Each bag has some distinct weight of gold between $1$ to $N$ . Japate can carry only one bag of gold with him, so he uses the following strategy to choose a bag.
Initially, he starts with an empty bag (zero weight). He considers the bags in some order. If the current bag has a higher weight than the bag in his hand, he picks the current bag.
Japate put the bags in some order. Japate realizes that he will pick $A$ bags, if he starts picking bags from the front, and will pick $B$ bags, if he starts picking bags from the back. By picking we mean replacing the bag in his hand with the current one.
Now he wonders how many permutations of bags are possible, in which he picks $A$ bags from the front and $B$ bags from back using the above strategy.
Since the answer can be very large, output it modulo $998244353$ .
Initially, he starts with an empty bag (zero weight). He considers the bags in some order. If the current bag has a higher weight than the bag in his hand, he picks the current bag.
Japate put the bags in some order. Japate realizes that he will pick $A$ bags, if he starts picking bags from the front, and will pick $B$ bags, if he starts picking bags from the back. By picking we mean replacing the bag in his hand with the current one.
Now he wonders how many permutations of bags are possible, in which he picks $A$ bags from the front and $B$ bags from back using the above strategy.
Since the answer can be very large, output it modulo $998244353$ .
输入格式
The only line of input contains three space separated integers $N$ ( $1<=N<=10^{5}$ ), $A$ and $B$ ( $0<=A,B<=N$ ).
输出格式
Output a single integer — the number of valid permutations modulo $998244353$ .
输入输出样例
输入 #1
1 1 1
输出 #1
1
输入 #2
2 1 1
输出 #2
0
输入 #3
2 2 1
输出 #3
1
输入 #4
5 2 2
输出 #4
22
In sample case $1$ , the only possible permutation is $[1]$
In sample cases $2$ and $3$ , only two permutations of size $2$ are possible: ${[1,2],[2,1]}$ . The values of $a$ and $b$ for first permutation is $2$ and $1$ , and for the second permutation these values are $1$ and $2$ .
In sample case $4$ , out of 120 permutations of $[1,2,3,4,5]$ possible, only 22 satisfy the given constraints of $a$ and $b$ .
In sample cases $2$ and $3$ , only two permutations of size $2$ are possible: ${[1,2],[2,1]}$ . The values of $a$ and $b$ for first permutation is $2$ and $1$ , and for the second permutation these values are $1$ and $2$ .
In sample case $4$ , out of 120 permutations of $[1,2,3,4,5]$ possible, only 22 satisfy the given constraints of $a$ and $b$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted