QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 2048 MB Total points: 100

#7923. 관람차

Statistics

대관람차 Cosmo Clock 21은 요코하마의 상징이며 도시의 야경을 아름답게 만듭니다. ICPC 시도 비슷한 것을 원합니다.

ICPC 시는 곤돌라 수가 짝수인 조명 관람차를 건설하려고 합니다. 모든 곤돌라는 주어진 후보 색 집합 중 한 가지 색으로 칠해야 합니다. 조명 계획은 다음과 같습니다:

  • 모든 곤돌라를 쌍으로 묶으며, 각 곤돌라는 정확히 한 쌍에 속합니다.

  • 같은 색의 곤돌라 두 개만 쌍을 이룰 수 있습니다.

  • 쌍을 이룬 곤돌라들은 직선 LED 선으로 연결하여 관람차를 밝힙니다.

  • 정면에서 보았을 때 어떤 두 LED 선도 교차하지 않습니다.

곤돌라의 색칠은 조명 계획에 맞게 쌍을 묶는 방법이 적어도 하나 존재하면 적합합니다.

problem_7923_e13cf180c1ad75a7eb42808fa8bd5a7f.png

그림 C.1. 적합한 색칠(왼쪽)과 적합하지 않은 색칠(오른쪽)의 관람차

곤돌라 수와 후보 색 수가 주어졌을 때, 적합한 곤돌라 색칠의 가짓수를 세세요. 관람차는 회전하므로, 어떤 회전에 의해 일치하는 두 색칠은 같은 것으로 간주합니다. 반대쪽에서 보았을 때만 일치하는 두 색칠은 서로 다른 것으로 간주합니다.

입력

입력은 다음 형식의 하나의 테스트 케이스로 이루어집니다.

$$n\quad k$$

$n$과 $k$는 $1$ 이상 $3\times10^6$ 이하의 정수입니다. 곤돌라 수와 후보 색 수는 각각 $2n$과 $k$입니다.

출력

적합한 곤돌라 색칠의 가짓수를 소수 $998\,244\,353=2^{23}\times7\times17+1$로 나눈 나머지를 출력하세요.

예제

입력 1

3 2

출력 1

6

입력 2

5 3

출력 2

372

입력 3

2023 1126

출력 3

900119621

참고

예제 입력 1에는 아래 그림과 같이 여섯 가지 적합한 색칠이 있습니다.

problem_7923_a41c1f7883e2438bd7b1f5fd3a5692c7.png

그림 C.2. $n=3$, $k=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.