309960: CF1765C. Card Guessing

Memory Limit:1024 MB Time Limit:15 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Card Guessing

题意翻译

有 $4$ 种花⾊的牌,每种牌均为 $n$ 张,则牌的排列⼀共有 $(4\cdot n)!$ 种。 现在你从牌堆中逐张地取出牌,取牌之前你都会猜⼀下这张牌是什么花⾊。你会根据之前的 $k$ 张牌中出现最少的花⾊来猜这张牌。 如果有多种花⾊都是最少的,你随机地猜⼀种。如果之前抽出的牌不⾜ $k$ 张,就按之前的所有牌中的最少花⾊来猜。 问你猜对的期望次数是多少?

题目描述

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.

输入输出格式

输入格式


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

Input

题意翻译

有 $4$ 种花⾊的牌,每种牌均为 $n$ 张,则牌的排列⼀共有 $(4\cdot n)!$ 种。 现在你从牌堆中逐张地取出牌,取牌之前你都会猜⼀下这张牌是什么花⾊。你会根据之前的 $k$ 张牌中出现最少的花⾊来猜这张牌。 如果有多种花⾊都是最少的,你随机地猜⼀种。如果之前抽出的牌不⾜ $k$ 张,就按之前的所有牌中的最少花⾊来猜。 问你猜对的期望次数是多少?

Output

题目大意:
这个题目是关于猜牌的问题。有4种花色的牌,每种花色有n张牌,所以牌的总数是4n张。牌的排列有(4n)!种可能。在抽牌之前,你都会猜测这张牌的花色。你会根据之前的k张牌中出现最少的花色来猜这张牌。如果有多种花色都是最少的,你随机地猜一种。如果之前抽出的牌不足k张,就按之前的所有牌中的最少花色来猜。问题是要求猜对的期望次数是多少?

输入输出数据格式:
输入格式:第一行包含两个整数n和k,分别表示每种花色的牌数和参考的牌数。
输出格式:输出一个整数,表示猜对的期望次数的值。

输入输出样例:
输入样例 #1:1 1
输出样例 #1:748683266
输入样例 #2:3 2
输出样例 #2:567184295
输入样例 #3:2 7
输出样例 #3:373153250
输入样例 #4:2 8
输出样例 #4:373153250题目大意: 这个题目是关于猜牌的问题。有4种花色的牌,每种花色有n张牌,所以牌的总数是4n张。牌的排列有(4n)!种可能。在抽牌之前,你都会猜测这张牌的花色。你会根据之前的k张牌中出现最少的花色来猜这张牌。如果有多种花色都是最少的,你随机地猜一种。如果之前抽出的牌不足k张,就按之前的所有牌中的最少花色来猜。问题是要求猜对的期望次数是多少? 输入输出数据格式: 输入格式:第一行包含两个整数n和k,分别表示每种花色的牌数和参考的牌数。 输出格式:输出一个整数,表示猜对的期望次数的值。 输入输出样例: 输入样例 #1:1 1 输出样例 #1:748683266 输入样例 #2:3 2 输出样例 #2:567184295 输入样例 #3:2 7 输出样例 #3:373153250 输入样例 #4:2 8 输出样例 #4:373153250

加入题单

上一题 下一题 算法标签: