A15475 | Card Guessing
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Consider a deck of cards. Each card has one of $4$ suits, and there are exactly $n$ cards for each suit — so, the total number of cards in the deck is $4n$ . The deck is shuffled randomly so that each of $(4n)!$ possible orders of cards in the deck has the same probability of being the result of shuffling. Let $c_i$ be the $i$ -th card of the deck (from top to bottom).
Monocarp starts drawing the cards from the deck one by one. Before drawing a card, he tries to guess its suit. Monocarp remembers the suits of the $k$ last cards, and his guess is the suit that appeared the least often among the last $k$ cards he has drawn. So, while drawing the $i$ -th card, Monocarp guesses that its suit is the suit that appears the minimum number of times among the cards $c_{i-k}, c_{i-k+1}, \dots, c_{i-1}$ (if $i \le k$ , Monocarp considers all previously drawn cards, that is, the cards $c_1, c_2, \dots, c_{i-1}$ ). If there are multiple suits that appeared the minimum number of times among the previous cards Monocarp remembers, he chooses a random suit out of those for his guess (all suits that appeared the minimum number of times have the same probability of being chosen).
After making a guess, Monocarp draws a card and compares its suit to his guess. If they match, then his guess was correct; otherwise it was incorrect.
Your task is to calculate the expected number of correct guesses Monocarp makes after drawing all $4n$ cards from the deck.
Monocarp starts drawing the cards from the deck one by one. Before drawing a card, he tries to guess its suit. Monocarp remembers the suits of the $k$ last cards, and his guess is the suit that appeared the least often among the last $k$ cards he has drawn. So, while drawing the $i$ -th card, Monocarp guesses that its suit is the suit that appears the minimum number of times among the cards $c_{i-k}, c_{i-k+1}, \dots, c_{i-1}$ (if $i \le k$ , Monocarp considers all previously drawn cards, that is, the cards $c_1, c_2, \dots, c_{i-1}$ ). If there are multiple suits that appeared the minimum number of times among the previous cards Monocarp remembers, he chooses a random suit out of those for his guess (all suits that appeared the minimum number of times have the same probability of being chosen).
After making a guess, Monocarp draws a card and compares its suit to his guess. If they match, then his guess was correct; otherwise it was incorrect.
Your task is to calculate the expected number of correct guesses Monocarp makes after drawing all $4n$ cards from the deck.
输入格式
The first (and only) line contains two integers $n$ ( $1 \le n \le 500$ ) and $k$ ( $1 \le k \le 4 \cdot n$ ).
输出格式
Let the expected value you have to calculate be an irreducible fraction $\dfrac{x}{y}$ . Print one integer — the value of $x \cdot y^{-1} \bmod 998244353$ , where $y^{-1}$ is the inverse to $y$ (i. e. an integer such that $y \cdot y^{-1} \bmod 998244353 = 1$ ).
输入输出样例
输入 #1
1 1
输出 #1
748683266
输入 #2
3 2
输出 #2
567184295
输入 #3
2 7
输出 #3
373153250
输入 #4
2 8
输出 #4
373153250
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted