Mike and Bob were playing with binary numbers. Mike was quite confident with his problem-solving skills, so he asks Bob to give him a challenge.
Bob gave him some Queries Q. For each query, Mike's task is to count the total numbers distinct of sequences that contain 0's and 1's of each length in the range [L, R] inclusive.
To make these tasks more challenging, Bob wanted that 0's must be present in a group of lengths divisible by K.
Mike needs your help to accomplish this challenge.
Note
Task
Find all the total numbers of unique sequences which follow the above conditions for each query.
Example
Assumptions
Approach
Here, Q = 2 and K = 3
Function Description
Complete the max_count function provided in the editor. This function takes the following 3 parameters and returns the answer integer.
Input Format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output Format
For each query(in a separate line), print the total numbers of unique/distinct sequences with length in range [L, R] and 0′s must be present in a group of lengths divisible by K. Don't forget to take modulo 1000000007(109+7)
Constraints
1≤Q≤5×1051≤K≤2×1051≤L≤R≤5×105
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
Here Q = 4, K = 3