#P10196. [USACO24FEB] Lazy Cow P
[USACO24FEB] Lazy Cow P
Description
Bessie is hard at work preparing test cases for the USA Cowmputing Olympiad February contest. Each minute, she can choose to not prepare any tests, expending no energy; or expend energy preparing test cases, for some positive integer .
Farmer John has () demands. For the th demand, he tells Bessie that within the first minutes, she needs to have prepared at least test cases in total ().
Let be the smallest amount of energy Bessie needs to spend to satisfy the first demands. Print modulo .
Input Format
The first line contains . The th of the next lines contains two space-separated integers and .
Output Format
Output lines, the th containing .
4
5 11
6 10
10 15
10 30
21
21
25
90
2
100 5
100 1000000000000
5
627323485
20
303590 482848034083
180190 112716918480
312298 258438719980
671877 605558355401
662137 440411075067
257593 261569032231
766172 268433874550
8114 905639446594
209577 11155741818
227183 874665904430
896141 55422874585
728247 456681845046
193800 632739601224
443005 623200306681
330325 955479269245
377303 177279745225
880246 22559233849
58084 155169139314
813702 758370488574
929760 785245728062
108753959
108753959
108753959
148189797
148189797
148189797
148189797
32884410
32884410
32884410
32884410
32884410
32884410
32884410
3883759
3883759
3883759
3883759
3883759
3883759
Hint
For Sample 1:
For the first test case,
- : If Bessie creates test cases on the first days, respectively, she would have expended units of energy and created test cases by the end of day .
- : Bessie can follow the above strategy to ensure test cases are created by the end of day , and this will automatically satisfy the second demand.
- : If Bessie creates test cases on the first days, respectively, she would have expended units of energy and satisfied all demands. It can be shown that she cannot expend less energy.
- : If Bessie creates 3 test cases on each of the first days she would have expended units of energy and satisfied all demands. For each , it can be shown that Bessie cannot satisfy the first demands using less energy.
SCORING:
- Inputs 4-5: and for all
- Inputs 6-8:
- Inputs 9-20: No additional constraints.
京公网安备 11011102002149号