Universal Cup Judging System

Universal Cup

Time Limit: 3.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Fizz Buzz City 是一個大型城市,因此它擁有一條環狀公路來幫助市民在各個區域之間移動也就不足為奇了。這條道路是環形的,既可以順時針通行,也可以逆時針通行。環狀公路的總長度恰好為 $\ell$ 公里,且其上有 $\ell$ 個路口。路口的設置使得沿著道路任意兩個相鄰路口之間的距離恰好為 $1$ 公里。

有一天,Fiodar 正在環狀公路上開車,突然想起需要幫汽車加油。不幸的是,他錯過了轉入加油站的路口!當然,由於交通法規的限制,他不能直接迴轉往回開。於是他在錯過轉彎後立即停下車,心想:「好吧,我就沿著環狀公路朝同一個方向一直開到下一個加油站。但如果太遠了怎麼辦?」

Fiodar 剛來到 Fizz Buzz City,所以他不知道加油站的確切位置。但他知道環狀公路上總共有 $n$ 個加油站。他還知道加油站只設在路口處,且不會有兩個加油站位於同一個路口。

「我想知道,為了確保能遇到至少一個加油站,我最多需要行駛多遠的距離?考慮到我不知道加油站是如何分佈的,如果每種分佈方案的機率均等,那麼在平均情況下,這個最大距離是多少?」Fiodar 心想。

你能幫他回答這個問題嗎?請找出無論他目前身處何處以及朝哪個方向行駛,為了遇到至少一個加油站而必須行駛的最大距離之期望值。假設所有合法的加油站配置方案都是等機率出現的。

輸入格式

唯一的一行包含兩個整數 $\ell$ 和 $n$($2 \le n \le \ell \le 10^6$):環狀公路的長度(單位:公里)與加油站的數量。

輸出格式

印出一個整數:所求最大距離期望值對 $998244353$ 取模的結果。

形式化地說,令 $M = 998244353$。可以證明答案能表示為最簡分數 $\frac{p}{q}$,其中 $p$ 和 $q$ 為整數且 $q \not\equiv 0 \pmod M$。請輸出等於 $p \cdot q^{-1} \bmod M$ 的整數。換句話說,輸出滿足 $0 \le x < M$ 且 $x \cdot q \equiv p \pmod M$ 的整數 $x$。

範例

輸入範例 1

2 2

輸出範例 1

1

輸入範例 2

5 3

輸出範例 2

499122179

輸入範例 3

20 5

輸出範例 3

796329095

說明

在第一個範例中,無論加油站如何配置,從道路上任意一點到加油站的最大距離都是 $1$。

在第二個範例中,有 $5$ 種配置方案的距離為 $(1, 2, 2)$(最大值為 $2$),以及 $5$ 種配置方案的距離為 $(1, 1, 3)$(最大值為 $3$)。因此,分數答案為 $\frac{5 \cdot 2 + 5 \cdot 3}{5 + 5} = \frac{5}{2}$。

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.