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

26437번 - Magical Well Of Lilies 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
15 초 (추가 시간 없음) 1024 MB47242253.659%

문제

There is a deep magical well in a forest that has some lilies on its waters. You have a large empty basket and some coins, and are standing next to the well. You have more coins than there are lilies in the well. The well has taken note of the fact that your basket is empty.

If you toss one coin into the well, the well will toss out one lily into your basket. If you toss four coins at once into the well, the well will take note of how many lilies it has tossed out into your basket so far. If you toss two coins at once into the well, the well will toss out as many lilies into your basket as it had last taken note of. If you toss one coin, or two coins at once, into the well, and there are not enough lilies left in the well, the well will not toss out any lilies.

Given the number of lilies $\mathbf{L}$ in the well at the beginning, return the minimum number of coins you will need to toss into the well to make it toss all of its lilies into your basket.

입력

The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ lines follow.

Each line contains a single integer $\mathbf{L},ドル representing the number of lilies in the well at the beginning.

출력

For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the minimum number of coins you will need to toss into the well to make it toss out all of its $\mathbf{L}$ lilies into your basket.

제한

Test Set 1 (8점)

  • 1ドル \le \mathbf{T} \le 20$.
  • 1ドル \le \mathbf{L} \le 20$.

Test Set 2 (13점)

  • 1ドル \le \mathbf{T} \le 100$.
  • 1ドル \le \mathbf{L} \le 10^5$.

예제 입력 1

2
5
20

예제 출력 1

Case #1: 5
Case #2: 15

For test case #1, when there are 5ドル$ lilies in the well, the least number of coins needed is 5ドル$. We toss them, one at a time, into the well, and the well tosses out the 5ドル$ lilies, one at a time, into our basket. No other sequence of moves results in a better solution, so 5ドル$ is our answer.

For test case #2, first, we toss 5ドル$ coins, one at a time, into the well, and the well tosses out 5ドル$ lilies, one at a time, into our basket. Next, we toss 4ドル$ coins at once into the well, and the well takes note that it has tossed out 5ドル$ lilies into our basket so far. Then, we toss 2ドル$ coins at once into the well, and the well tosses out 5ドル$ lilies (that it took note of) into our basket. Then, we toss another 2ドル$ coins at once into the well, and the well tosses out another 5ドル$ lilies into our basket. Finally, we toss another 2ドル$ coins at once into the well, and the well tosses out the final 5ドル$ lilies into our basket. Total coins needed is 15ドル$. Getting 20ドル$ lilies out of the well is not possible with any lesser number of coins, so 15ドル$ is our answer.

힌트

출처

Contest > Google > Kick Start > Google Kick Start 2022 > Round H B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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