解题思路:
(1)每次剩余汽水瓶的个数为:n = n/3+n%3
(2)最后剩两个的时候,可以借一瓶凑够三瓶
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main() {
int n,count,y,s;
while(cin>>n) {
if(n==0) break;
count = 0;
while(n>=3) {
y = n%3;
s = n/3;
n = y+s;
count+=s;
}
if(n==2) cout<<count+1<<endl;
else cout<<count<<endl;
}
return 0;
}