CF1765C.Card Guessing

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider a deck of cards. Each card has one of 44 suits, and there are exactly nn cards for each suit — so, the total number of cards in the deck is 4n4n . The deck is shuffled randomly so that each of (4n)!(4n)! possible orders of cards in the deck has the same probability of being the result of shuffling. Let cic_i be the ii -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 kk last cards, and his guess is the suit that appeared the least often among the last kk cards he has drawn. So, while drawing the ii -th card, Monocarp guesses that its suit is the suit that appears the minimum number of times among the cards cik,cik+1,,ci1c_{i-k}, c_{i-k+1}, \dots, c_{i-1} (if iki \le k , Monocarp considers all previously drawn cards, that is, the cards c1,c2,,ci1c_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 4n4n cards from the deck.

输入格式

The first (and only) line contains two integers nn ( 1n5001 \le n \le 500 ) and kk ( 1k4n1 \le k \le 4 \cdot n ).

输出格式

Let the expected value you have to calculate be an irreducible fraction xy\dfrac{x}{y} . Print one integer — the value of xy1mod998244353x \cdot y^{-1} \bmod 998244353 , where y1y^{-1} is the inverse to yy (i. e. an integer such that yy1mod998244353=1y \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
首页