CF1765C.Card Guessing
省选/NOI-
通过率:0%
时间限制:15.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 ci 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 ci−k,ci−k+1,…,ci−1 (if i≤k, Monocarp considers all previously drawn cards, that is, the cards c1,c2,…,ci−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.
考虑一副扑克牌。每张牌有 4 种花色之一,且每种花色恰好有 n 张牌——因此,整副牌共有 4n 张牌。这副牌被随机洗牌,使得 (4n)! 种可能的牌序中每一种出现的概率均相等。令 ci 表示牌堆中自上而下的第 i 张牌。
Monocarp 开始依次从牌堆中抽牌。在抽出一张牌之前,他尝试猜测该牌的花色。Monocarp 会记住最近抽到的 k 张牌的花色,其猜测依据是:在最近抽到的 k 张牌中,出现次数最少的花色。具体而言,在抽出第 i 张牌时,Monocarp 猜测其花色为牌 ci−k,ci−k+1,…,ci−1 中出现次数最少的花色(若 i≤k,则 Monocarp 考虑所有此前已抽出的牌,即牌 c1,c2,…,ci−1)。若在 Monocarp 所记住的前几张牌中,有多个花色出现次数同为最小值,则他从中随机选择一个作为猜测(即所有出现次数最少的花色被选中的概率相等)。
做出猜测后,Monocarp 抽出一张牌,并将其实际花色与自己的猜测进行比对。若二者一致,则此次猜测正确;否则为错误。
你的任务是计算 Monocarp 抽完全部 4n 张牌后,所作猜测中正确的次数的期望值。
输入格式
The first (and only) line contains two integers n (1≤n≤500) and k (1≤k≤4⋅n).
第一行(也是唯一一行)包含两个整数 n(1≤n≤500)和 k(1≤k≤4⋅n)。
输出格式
Let the expected value you have to calculate be an irreducible fraction yx. Print one integer — the value of x⋅y−1mod998244353, where y−1 is the inverse to y (i. e. an integer such that y⋅y−1mod998244353=1).
设你需要计算的期望值为一个既约分数 yx。输出一个整数 —— x⋅y−1mod998244353 的值,其中 y−1 是 y 的模逆元(即满足 y⋅y−1mod998244353=1 的整数)。
输入输出样例
输入#1
1 1
输出#1
748683266
输入#2
3 2
输出#2
567184295
输入#3
2 7
输出#3
373153250
输入#4
2 8
输出#4
373153250
输入解题思路,AI测评打分。不知道怎么写?