Logo
(追記) (追記ここまで)

31651번 - Lazy Cow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB35151548.387%

문제

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 3ドル^{a-1}$ energy preparing $a$ test cases, for some positive integer $a$.

Farmer John has $D$ (1ドル\le D\le 2\cdot 10^5$) demands. For the $i$th demand, he tells Bessie that within the first $m_i$ minutes, she needs to have prepared at least $b_i$ test cases in total (1ドル\le m_i\le 10^6, 1 \leq b_i \leq 10^{12}$).

Let $e_i$ be the smallest amount of energy Bessie needs to spend to satisfy the first $i$ demands. Print $e_1,\dots,e_D$ modulo 10ドル^9+7$.

입력

The first line contains $D$. The $i$th of the next $D$ lines contains two space-separated integers $m_i$ and $b_i$.

출력

Output $D$ lines, the $i$th containing $e_i \text{ mod } 10^9+7$.

제한

예제 입력 1

4
5 11
6 10
10 15
10 30

예제 출력 1

21
21
25
90

For the first test case,

  • $i=1$: If Bessie creates $[2, 3, 2, 2, 2]$ test cases on the first 5ドル$ days, respectively, she would have expended 3ドル^1 + 3^2 + 3^1 + 3^1 + 3^1 = 21$ units of energy and created 11ドル$ test cases by the end of day 5ドル$.
  • $i=2$: Bessie can follow the above strategy to ensure 11ドル$ test cases are created by the end of day 5ドル,ドル 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 first 10ドル$ days, respectively, she would have expended 25ドル$ 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 first 10ドル$ days she would have expended 3ドル^{2}\cdot 10 = 90$ units of energy and satisfied all demands.

For each $i,ドル it can be shown that Bessie cannot satisfy the first $i$ demands using less energy.

예제 입력 2

2
100 5
100 1000000000000

예제 출력 2

5
627323485

예제 입력 3

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

예제 출력 3

108753959
108753959
108753959
148189797
148189797
148189797
148189797
32884410
32884410
32884410
32884410
32884410
32884410
32884410
3883759
3883759
3883759
3883759
3883759
3883759

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 February Contest > Platinum 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /