Magical Well Of Lilies
시간 제한15초메모리 제한1024 MB
동전 1개, 2개, 4개를 던지는 세 가지 행동으로 우물에서 백합을 꺼낼 때, 정확히 L개를 얻는 데 필요한 최소 동전 수를 구한다.
문제
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 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, . lines follow.
Each line contains a single integer , representing the number of lilies in the well at the beginning.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the minimum number of coins you will need to toss into the well to make it toss out all of its lilies into your basket.