题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include<iostream> using namespace std; //观察数据,取巧法 int CalcNuMber_1(int n) { return n/2; } //概念法 int CalcNumber(int n) { int sum=0; while(n>1) { int res=n/3; int left=n%3; sum+=res; n=left+res; if(n==2) { sum++; break; } } return sum; } int main() { int n; while(cin>>n) { if(n==0) break; int res=CalcNuMber_1(n); //int res=CalcNumber(n); cout<<res<<endl; } return 0; }