#H. G - Black and White Stones

    传统题 2000ms 1024MiB

G - Black and White Stones

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

G - Black and White Stones

Score : $600$ points

Problem Statement

There is a regular $N$-gon with side length $D$.

Starting from a vertex, we place black or white stones on the circumference at intervals of $1$. As a result, each edge of the $N$-gon will have $(D+1)$ stones on it, for a total of $ND$ stones.

How many ways are there to place stones so that all edges have the same number of white stones on them? Find the count modulo $998244353$.

Constraints

  • $3 \leq N \leq 10^{12}$
  • $1 \leq D \leq 10^4$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN DD

Output

Print the answer.


3 2
10

There are $10$ ways, as follows:

Figure


299792458 3141
138897974

Find the count modulo $998244353$.

2024春季入门组刷题营(七)

未参加
状态
已结束
规则
IOI
题目
8
开始于
2024-4-21 13:00
结束于
2024-4-21 15:00
持续时间
2 小时
主持人
参赛人数
12