Universal Cup Judging System

Universal Cup

Time Limit: 6.0 s Memory Limit: 2048 MB Total points: 100 Difficulty: [show] Hackable ✓
Statistics

小青魚正在對區間集合進行研究。

喺呢題入面,我哋用 $[l, r]$ 代表區間 $\{x \mid l \le x \le r\}$。對於一個包含區間 $[l, r]$ 嘅集合 $S$,當且僅當滿足以下三個條件時,稱其為 Cyanic 集合:

  1. $S \subseteq \{[l, r] \mid l, r \in \mathbb{Z}, 0 \le l \le r \le n\}$。即係 $S$ 入面嘅每個元素都係端點為整數而且包含喺 $[0, n]$ 內嘅閉區間 $[l, r]$。
  2. 對於所有整數 $i \in [0, n]$,區間 $[i, i] \in S$。
  3. 對於任意兩個區間 $[l_0, r_0] \in S$ 同 $[l_1, r_1] \in S$,如果 $l_0 \le l_1 < r_0 \le r_1$,咁區間 $[l_0, l_1]$ 同 $[r_0, r_1]$ 亦必須屬於 $S$。

為咗幫你理解,小青魚考慮咗 $n = 3$ 時嘅以下幾種情況:

  • 集合 $\{[0, 0], [2, 2]\}$ 唔係 Cyanic 集合。區間 $[1, 1] \notin S$,因此違反咗第二個條件。
  • 集合 $\{[0, 0], [1, 1], [2, 2], [3, 3], [0, 2], [1, 3]\}$ 唔係 Cyanic 集合。當我哋揀 $[l_0, r_0] = [0, 2]$ 同 $[l_1, r_1] = [1, 3]$ 時,區間 $[l_0, l_1] = [0, 1] \notin S$,因此違反咗第三個條件。
  • 集合 $\{[0, 0], [1, 1], [2, 2], [3, 3], [0, 2], [0, 1], [1, 2]\}$ 係一個 Cyanic 集合。
  • 集合 $\{[0, 0], [1, 1], [2, 2], [3, 3], [0, 3], [1, 2]\}$ 亦係一個 Cyanic 集合。

當然,存在非常非常多嘅 Cyanic 集合,小青魚鍾意佢哋全部。設 $\mathcal{C}$ 為所有 Cyanic 集合構成嘅集合。對於給定嘅整數 $q$,小青魚想知道以下總和嘅值:

$$\sum_{S \in \mathcal{C}} q^{|S|}$$

由於呢個總和可能非常大,小青魚請你計算該總和對 $998\,244\,353$ 取模後嘅結果。

輸入格式

輸入嘅第一行包含兩個整數 $n$ ($1 \le n \le 10^5$) 同 $q$ ($1 \le q < 998\,244\,353$)。

輸出格式

輸出單行,包含一個整數,代表答案。

樣例

輸入 1

1 2

輸出 1

12

說明

對於樣例 1:存在兩個 Cyanic 集合 $\{[0, 0], [1, 1]\}$ 同 $\{[0, 0], [1, 1], [0, 1]\}$,因此答案為 $2^2 + 2^3 = 12$。

輸入 2

3 1

輸出 2

22

輸入 3

10 3

輸出 3

855061512

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1116EditorialOpen乐灵的题解。QingyuView

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.