atcoder#ABC255H. [ABC255Ex] Range Harvest Query
[ABC255Ex] Range Harvest Query
Score : points
Problem Statement
There are trees. On Day , each tree bears no fruits. On the morning of Day and subsequent days, the -th tree bears new fruits for each .
Takahashi will perform harvesting. For each , the -th harvesting takes place on the night of Day , collecting all fruits remaining on the -th through -th trees at that point.
For each of the harvesting, print the number of fruits Takahashi will collect, modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. For each , the -th line should contain the number of fruits Takahashi will collect in the -th harvesting, modulo .
5 3
2 2 3
3 3 4
5 1 5
10
15
50
For each , let be the number of fruits remaining on the -th tree. Now, we use the sequence to represent the numbers of fruits remaining in the trees.
- On Day , we have .
- On the morning of Day , each tree bears new fruits, and we have .
- On the morning of Day , each tree bears new fruits, and we have .
- On the night of Day , Takahashi performs the -st harvesting. fruits are collected, and we have .
- On the morning of Day , each tree bears new fruits, and we have .
- On the night of Day , Takahashi performs the -nd harvesting. fruits are collected, and we have .
- On the morning of Day , each tree bears new fruits, and we have .
- On the morning of Day , each tree bears new fruits, and we have .
- On the night of Day , Takahashi performs the -rd harvesting. fruits are collected, and we have .
711741968710511029 1
82803157126515475 516874290286751784 588060532191410838
603657470
Be sure to print the numbers modulo .