AtCoder Grand Contest 061
翻译中…
Problem Statement
翻译中…
There are positive integers $N$ and $M$.
翻译中…
A binary string $s$ is called good if all of the followings are satisfied:
翻译中…
$s$is non-empty.- The number of
1s in$s$is a multiple of$N$. - The number of
0s in$s$is a multiple of$M$.
翻译中…
A good string is called perfect if it doesn't contain shorter good (contiguous) substrings. For example, if $N = 3$ and $M = 2$, then strings 111, 00 and 10101 are perfect, but 0000 and 11001 are not.
翻译中…
One can show that for any $N, M$ the number of perfect strings is finite. Find this number modulo $998\,244\,353$.
翻译中…
Constraints
翻译中…
$1 \leq N, M \leq 40$- All values in the input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N M
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
2 2
Output #1
4
The perfect strings are `00`, `0101`, `1010`, `11`.
Input #2
3 2
Output #2
7
The perfect strings are `00`, `01011`, `01101`, `10101`, `10110`, `11010`, `111`.
Input #3
23 35
Output #3
212685109
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。