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.