#abc300h. Ex - Fibonacci: Revisited

Ex - Fibonacci: Revisited

Score : 600600 points

问题陈述

我们通过以下方式定义序列 a0,a1,a2,a_0, a_1, a_2, \dots 的一般项 ana_n

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

给定一个整数 NN,求满足 m AND N=mm\text{ AND }N = m 的所有非负整数 mm 对应的 ama_m 之和,模 998244353998244353

什么是按位与(bitwise AND)?两个非负整数 AABB 的按位与运算 A AND BA\text{ AND }B 定义如下: ・当以二进制表示 A AND BA\text{ AND }B 时,其在 2k2^k 位上(k0k \geq 0)的值为 11,当且仅当 AABB2k2^k 位上都为 11,否则为 00

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We define the general term ana_n of a sequence a0,a1,a2,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 NN, find the sum, modulo 998244353998244353, of ama_m over all non-negative integers mm such that m AND N=mm\text{ AND }N = m. (AND\text{AND} denotes the bitwise AND.)

What is bitwise AND? The bitwise AND of non-negative integers AA and BB, A AND BA\text{ AND }B, is defined as follows.
・When A AND BA\text{ AND }B is written in binary, its 2k2^ks place (k0k \geq 0) is 11 if 2k2^ks places of AA and BB are both 11, and 00 otherwise.

Constraints

  • 1K5×1041 \leq K \leq 5 \times 10^4
  • 0N10180 \leq N \leq 10^{18}
  • NN and KK are integers.

Input

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

KK NN

Output

Print the answer.

Sample Input 1

2 6

Sample Output 1

21

a0a_0 and succeeding terms are 1,1,2,3,5,8,13,21,1, 1, 2, 3, 5, 8, 13, 21, \dots. Four non-negative integers, 0,2,40, 2, 4, and 66, satisfy 6 AND m=m6 \text{ AND } m = m, so the answer is 1+2+5+13=211 + 2 + 5 + 13 = 21.

Sample Input 2

2 8

Sample Output 2

35

Sample Input 3

1 123456789

Sample Output 3

65536

Sample Input 4

300 20230429

Sample Output 4

125461938

Sample Input 5

42923 999999999558876113

Sample Output 5

300300300

update @ 2024/3/10 08:25:15