문제
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
Farmer John has
Let
입력
The first line contains
출력
Output
부분문제
| 번호 | 점수 | 조건 |
|---|---|---|
| #1 | 20점 | |
| #2 | 30점 | |
| #3 | 50점 | 추가 제약 조건 없음 |
예제 #1
4
5 11
6 10
10 15
10 30
21
21
25
90
For the first test case,
i=1 : If Bessie creates[2, 3, 2, 2, 2] test cases on the first5 days, respectively, she would have expended3^1 + 3^2 + 3^1 + 3^1 + 3^1 = 21 units of energy and created11 test cases by the end of day5 .i=2 : Bessie can follow the above strategy to ensure11 test cases are created by the end of day5 , and this will automatically satisfy the second demand.i=3 : If Bessie creates[2, 3, 2, 2, 2, 0, 1, 1, 1, 1] test cases on the first10 days, respectively, she would have expended25 units of energy and satisfied all demands. It can be shown that she cannot expend less energy.i=4 : If Bessie creates 3 test cases on each of the first10 days she would have expended units of energy and satisfied all demands.
For each
예제 #2
2
100 5
100 1000000000000
108753959
108753959
108753959
148189797
148189797
148189797
148189797
32884410
32884410
32884410
32884410
32884410
32884410
32884410
3883759
3883759
3883759
3883759
3883759
3883759