ユニークビジョンプログラミングコンテスト2023 春 (AtCoder Beginner Contest 300)
Ex
Fibonacci: Revisited
AtCoder
⌀ 3209
原题
←G →
翻译中…

Problem Statement

翻译中…

We define the general term $a_n$ of a sequence $a_0, a_1, a_2, \dots$ by:

翻译中…

$a_n = \begin{cases} 1 & (0 \leq n \lt K) \\ \displaystyle{\sum_{i=1}^K} a_{n-i} & (K \leq n). \\ \end{cases}$

翻译中…

Given an integer $N$, find the sum, modulo $998244353$, of $a_m$ over all non-negative integers $m$ such that $m\text{ AND }N = m$. ($\text{AND}$ denotes the bitwise AND.)

翻译中…

What is bitwise AND? The bitwise AND of non-negative integers $A$ and $B$, $A\text{ AND }B$, is defined as follows. ・When $A\text{ AND }B$ is written in binary, its $2^k$s place ($k \geq 0$) is $1$ if $2^k$s places of $A$ and $B$ are both $1$, and $0$ otherwise.

翻译中…

Constraints

翻译中…
  • $1 \leq K \leq 5 \times 10^4$
  • $0 \leq N \leq 10^{18}$
  • $N$ and $K$ are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

K N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
2 6
Output #1
21
$a_0$ and succeeding terms are $1, 1, 2, 3, 5, 8, 13, 21, \dots$. Four non-negative integers, $0, 2, 4$, and $6$, satisfy $6 \text{ AND } m = m$, so the answer is $1 + 2 + 5 + 13 = 21$.
Input #2
2 8
Output #2
35
Input #3
1 123456789
Output #3
65536
Input #4
300 20230429
Output #4
125461938
Input #5
42923 999999999558876113
Output #5
300300300
题目信息

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