题解 | 汽水瓶
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include <iostream>
using namespace std;
int bottle(int n){
int count=0;
if(n==1)return 0;
if(n==2)return 1;
if(n>=3)
count=n/3+bottle(n/3+n%3);
return count;
}
int main() {
int n;
while(cin>>n){
if(n==0)break;
cout<<bottle(n)<<endl;
}
}
// 64 位输出请用 printf("%lld")
非常简单的递归

