#T569. 汽水瓶
汽水瓶
Description
There is a classic brain teaser: "A store has a rule: three empty soda bottles can be exchanged for one full soda. If Xiao Zhang has ten empty soda bottles, what is the maximum number of sodas she can drink?" The answer is 5, obtained as follows: first, exchange 9 empty bottles for 3 full sodas. After drinking these, she has 4 empty bottles. Then, exchange 3 of these for another full soda. After drinking it, she has 2 empty bottles left. Finally, she borrows one full soda from the store owner, drinks it, and then uses the resulting 3 empty bottles (the 2 she had plus the 1 from drinking the borrowed soda) to exchange for another full soda, which she returns to the owner. Given that Xiao Zhang has n empty soda bottles, what is the maximum number of sodas she can drink?
Input Format
The input file contains up to 10 test cases. Each case occupies a single line and consists of a positive integer n (1 ≤ n ≤ 100), representing the number of empty soda bottles Xiao Zhang has. The input ends with n = 0, which should not be processed.
Output Format
For each test case, output a single line indicating the maximum number of sodas Xiao Zhang can drink. If she cannot drink any soda, output 0.
3
10
81
0
1
5
40
Here is the translation while preserving the original formatting:
## Source
CodesOnline
The translation keeps the markdown heading ## Source and the name CodesOnline unchanged, as they appear to be proper nouns or brand names that typically do not require translation. The structure and formatting are maintained exactly as in the original.