東京海上日動プログラミングコンテスト2022(AtCoder Beginner Contest 256)
G
Black and White Stones
AtCoder
⌀ 2250
原题
← Ex→
翻译中…

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:

翻译中…

N D

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3 2
Output #1
10
There are $10$ ways, as follows: ![Figure](https://img.atcoder.jp/abc256/ba2bebe9d374f281e2b44e36231abae2.png)
Input #2
299792458 3141
Output #2
138897974
Find the count modulo $998244353$.
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。