Universal Cup Judging System

Universal Cup

Límite de tiempo: 3.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓
Estadísticas

有 $N$ 個箱子,每個箱子分別標記著從 $1$ 到 $N$ 的整數。此外,對於每個從 $1$ 到 $N$ 的整數,都有 $M$ 個標記著該整數的球。

這些 $NM$ 個球被洗牌後分配到 $N$ 個箱子中,每個箱子恰好放入 $M$ 個球。

將球放入箱子的方式共有 $\frac{(NM)!}{(M!)^N}$ 種(若視所有球為可區分),且這些排列出現的機率相等。

你將對這些箱子和球執行操作。一次操作包含以下步驟:

  1. 選擇一個箱子並走到該箱子前方。
  2. 若該箱子內沒有球,則終止操作。
  3. 從該箱子中選擇任意一個球並將其丟棄到箱子外。
  4. 最後,走到標籤與剛丟棄的球之標籤相同的箱子前方,並回到步驟 2。

定義你的分數為直到所有 $NM$ 個球都被丟棄為止所需的操作次數。你希望最小化此分數。

請找出當你採取最佳策略時,分數的期望值,並對 $998244353$ 取模。

輸入格式

第一行包含 $N$ 和 $M$,兩者以空格分隔。($1 \le N \le 10^5$, $1 \le M \le 100$)

輸出格式

輸出答案。

範例

輸入格式 1

2 2

輸出格式 1

166374060

輸入格式 2

3 1

輸出格式 2

831870296

輸入格式 3

100000 100

輸出格式 3

402978825

說明

對於第一個範例,可能的球排列方式以及對應的最佳操作方式如下:

  • 將兩個標記為 1 的球放入箱子 1,將兩個標記為 2 的球放入箱子 2。(機率 $1/6$)

    • 在第一次操作中,走到箱子 1 前方。從那裡取出一個標記為 1 的球,並走到箱子 1 前方。接著再取出另一個標記為 1 的球,並再次走到箱子 1 前方。此時,箱子 1 為空,因此終止操作。
    • 在第二次操作中,走到箱子 2 前方。從那裡取出一個標記為 2 的球,並走到箱子 2 前方。接著再取出另一個標記為 2 的球,並再次走到箱子 2 前方。此時,箱子 2 為空,因此終止操作。
    • 在此情況下,最小可達成分數為 2。
  • 將一個標記為 1 的球和一個標記為 2 的球放入箱子 1 和箱子 2。(機率 $2/3$)

    • 在第一次操作中,走到箱子 1 前方。從那裡取出一個標記為 1 的球,並走到箱子 1 前方。接著取出一個標記為 2 的球,並走到箱子 2 前方。接著取出一個標記為 2 的球,並走到箱子 2 前方。接著取出一個標記為 1 的球,並走到箱子 1 前方。此時,箱子 1 為空,因此終止操作。
    • 在此情況下,最小可達成分數為 1。
  • 將兩個標記為 2 的球放入箱子 1,將兩個標記為 1 的球放入箱子 2。(機率 $1/6$)

    • 在第一次操作中,走到箱子 1 前方。從那裡取出一個標記為 2 的球,並走到箱子 2 前方。接著取出一個標記為 1 的球,並走到箱子 1 前方。接著取出一個標記為 2 的球,並走到箱子 2 前方。接著取出一個標記為 1 的球,並走到箱子 1 前方。此時,箱子 1 為空,因此終止操作。
    • 在此情況下,最小可達成分數為 1。

總結來說,最小分數為 2 的機率為 $1/6$,最小分數為 1 的機率為 $5/6$,因此總期望分數為 $7/6$。因此,輸出 $166374060$,這代表該數值對 $998244353$ 取模後的結果。

可以證明所求的期望值總是一個有理數。此外,在本問題的限制條件下,若期望值寫成最簡分數 $\frac{y}{x}$,則保證 $x$ 不能被 $998244353$ 整除。

在此情況下,存在唯一的整數 $z$ 滿足 $0 \le z \le 998244352$,且滿足 $xz \equiv y \pmod{998244353}$。請輸出此 $z$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1526EditorialOpen题解jiangly2026-04-15 16:03:55View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.