#abc255h. Ex - Range Harvest Query
Ex - Range Harvest Query
Score : points
问题描述
有 棵树。在第 天,每棵树上都没有果实。
从第 天早晨开始及随后的每一天,第 棵树将结出 个新的果实,对于每个 。
高桥将进行 次采集。对于每个 ,第 次采集发生在第 天的晚上,收集此时第 到第 棵树上所有剩余的果实。
对于这 次采集中的每一次,输出高桥将收集到的果实总数,结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
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 .
Sample Input 1
5 3
2 2 3
3 3 4
5 1 5
Sample Output 1
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 .
Sample Input 2
711741968710511029 1
82803157126515475 516874290286751784 588060532191410838
Sample Output 2
603657470
Be sure to print the numbers modulo .
update @ 2024/3/10 10:52:40