#T772. 汽水瓶
汽水瓶
Description
There is a classic brain teaser: "A store has a rule: three empty soda bottles can be exchanged for one soda. If Xiao Zhang has ten empty soda bottles, how many sodas can she drink at most?" The answer is 5, and the method is as follows: First, exchange 9 empty bottles for 3 sodas. After drinking these 3 full bottles, there are 4 empty bottles. Then, exchange 3 of them for another soda. After drinking this full bottle, there are 2 empty bottles left. Next, you ask the store owner to lend you one soda. After drinking this full bottle, you use the 3 empty bottles to exchange for another full soda and return it to the owner. If Xiao Zhang has n empty soda bottles, how many sodas can she drink at most?
Input Format
The input file contains up to 10 test cases. Each case occupies one line and consists of a single positive integer n (1 ≤ n ≤ 100), representing the number of empty soda bottles Xiao Zhang has. A line with n = 0 indicates the end of input, and your program should not process this line.
Output Format
For each test case, output one line indicating the maximum number of sodas that can be drunk. If no soda can be drunk, output 0.
3
10
81
0
1
5
40
译文
CodesOnline