atcoder#ABC300H. [ABC300Ex] Fibonacci: Revisited
[ABC300Ex] Fibonacci: Revisited
Score : points
Problem Statement
We define the general term of a sequence 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 , find the sum, modulo , of over all non-negative integers such that . ( 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^ks place (k \geq 0) is 1 if 2^ks places of A and B are both 1, and 0 otherwise.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
2 6
21
and succeeding terms are . Four non-negative integers, , and , satisfy , so the answer is .
2 8
35
1 123456789
65536
300 20230429
125461938
42923 999999999558876113
300300300