The Magical Stone CodeChef Solution | CodeChef Problem Solution 2022
Initially, there is a magical stone of mass lying at the origin of the number line. For the next seconds, the following event happens:
- Let us define the decomposition of a magical stone as follows: If there is a magical stone of mass lying at coordinate , then it decomposes into two magical stones, each of mass lying at the coordinates and respectively. The original stone of mass gets destroyed in the process.
- Each second, all the magical stones undergo decomposition simultaneously.
Note that there can be more than one stone at any coordinate .
Given a range , find out the number of stones present at each of the coordinates in the range . As the number of stones can be very large, output them modulo .
Input Format
- The first line contains a single integer - the number of test cases. Then the test cases follow.
- The first and only line of each test case contains three integers , and , as described in the problem statement.
Output Format
For each testcase, output in a single line a total of space-separated integers. The integer will denote the number of stones present at coordinate. As the number of stones can be very large, output them modulo .
Constraints
- Sum of over all the test cases doesn't exceed .
Sample Input 1
3
2 -2 2
2 0 2
150000 48 48
Sample Output 1
1 0 2 0 1
2 0 1
122830846
Explanation
Test case 1: Let us look at the number of stones for to as the time progresses:
:
:
:
We have to output the number of stones at to , which is .
Test case 2: Similar to first test case, We have to output the number of stones at to , which is .
Join Now for Solution:-
No comments:
Post a Comment