AT_arc230_e.Minister

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given positive integers NN and MM.

A box contains one ball numbered 11, one ball numbered 22, …\dots, one ball numbered NN. There is also a blackboard with nothing written on it. Using these, Alice plays the following game.

First, Alice draws one ball from the box uniformly at random and keeps it at hand. Then, Alice performs the following sequence of operations N−1N-1 times.

  • Draw one ball from the box uniformly at random, independently of the previous operations, and keep it at hand.

  • Write the sum of the numbers of the two balls at hand on the blackboard.

  • Freely choose exactly one of the two balls at hand to discard, and keep the other at hand.

Alice's score in this game is defined as follows: it is 00 if the maximum value of the integers written on the blackboard is MM or greater, and otherwise it is the number of the ball finally kept at hand.

Find the expected value, modulo 998244353998244353, of Alice's score when she acts to maximize the expected value of her score.

Definition of expected value modulo 998244353998244353

It can be proved that the sought expected value is always a rational number. Also, under the constraints of this problem, it can be proved that when that value is represented as an irreducible fraction AB\frac{A}{B}, we have B≢0(mod998244353)B {{}\not\equiv{}} 0 \pmod{998244353}. Therefore, there is a unique integer CC such that C×B≡A(mod998244353),0≤C<998244353C \times B \equiv A \pmod{998244353}, 0 \leq C < 998244353. Report this CC.

给定正整数 NN 和 MM。

一个盒子中包含编号为 11 的球一个、编号为 22 的球一个、……、编号为 NN 的球一个。另有一块黑板,初始为空。Alice 使用这些物品进行如下游戏:

首先,Alice 从盒子中均匀随机抽取一个球,并将其持于手中。随后,Alice 重复执行以下操作共 N−1N-1 次:

  • 从盒子中独立地、均匀随机抽取一个球(与之前所有操作无关),并将其持于手中;
  • 将手中两个球的编号之和写在黑板上;
  • 自由选择手中两个球中的恰好一个丢弃,另一个继续持于手中。

定义 Alice 在本局游戏中的得分为:若黑板上所写整数的最大值 大于等于 MM,则得分为 00;否则,得分为最后留在手中的那个球的编号。

当 Alice 以最大化其得分期望值的方式行动时,求其得分的期望值对 998244353998244353 取模的结果。

关于“对 998244353998244353 取模的期望值”的定义:

可以证明,所求期望值恒为有理数。此外,在本题约束下还可证明:若将该值表示为既约分数 AB\frac{A}{B},则必有 B≢0(mod998244353)B {{}\not\equiv{}} 0 \pmod{998244353}。因此,存在唯一整数 CC 满足

C×B≡A(mod998244353),0≤C<998244353.C \times B \equiv A \pmod{998244353}, \quad 0 \leq C < 998244353.

请输出该 CC。

输入格式

The input is given from Standard Input in the following format:

NN MM

输入从标准输入中以如下格式给出:

NN MM

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    3 5

    输出#1

    665496237
  • 输入#2

    10 10

    输出#2

    0
  • 输入#3

    30 40

    输出#3

    377125280

说明/提示

Sample 1 Explanation:
The following is one possible scenario of the game.

  1. One ball is drawn from the box, and its number is 33. This ball is kept at hand.

  2. One ball is drawn from the box, and its number is 11. This ball is kept at hand. The numbers of the two balls at hand are now 1,31,3.

  3. Write 1+3=41+3=4 on the blackboard.

  4. Discard the ball numbered 33, keeping the ball numbered 11 at hand.

  5. One ball is drawn from the box, and its number is 22. This ball is kept at hand. The numbers of the two balls at hand are now 1,21,2.

  6. Write 1+2=31+2=3 on the blackboard.

  7. Discard the ball numbered 11, keeping the ball numbered 22 at hand.

  8. Since the maximum value of the integers written on the blackboard is not 55 or greater, Alice obtains a score of 22, the number of the ball finally kept at hand.

This scenario is not necessarily the result of Alice acting to maximize the expected value of her score.

The sought expected value is 53 mod 998244353=665496237\dfrac{5}{3} \bmod{998244353}=665496237.

Constraints

  • 2≤N≤30002 \le N \le 3000
  • 1≤M≤2N1 \le M \le 2N
  • All input values are integers.

样例 1 解释:
以下是游戏的一种可能情形。

  1. 从盒子中随机取出一个球,其编号为 33。该球被保留在手中。
  2. 从盒子中随机取出一个球,其编号为 11。该球被保留在手中。此时手中两个球的编号为 1,31,3。
  3. 在黑板上写下 1+3=41+3=4。
  4. 丢弃编号为 33 的球,仅保留编号为 11 的球在手中。
  5. 从盒子中随机取出一个球,其编号为 22。该球被保留在手中。此时手中两个球的编号为 1,21,2。
  6. 在黑板上写下 1+2=31+2=3。
  7. 丢弃编号为 11 的球,仅保留编号为 22 的球在手中。
  8. 由于黑板上所写整数的最大值未达到 55 或更大,Alice 的得分为 22,即最终保留在手中的球的编号。

该情形未必是 Alice 为最大化其得分期望值而采取的最优策略所导致的结果。

所求的期望值为 53 mod 998244353=665496237\dfrac{5}{3} \bmod{998244353}=665496237。

约束条件

  • 2≤N≤30002 \le N \le 3000
  • 1≤M≤2N1 \le M \le 2N
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页