题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include <iostream> using namespace std; int main() { int num; while (cin >> num) { // 注意 while 处理多个 case if(num == 0){ break; } int full = 0; int empty = num; int res = 0; //cout<<empty<<endl; while (empty / 3 >= 1) { full = empty / 3; res += full; empty = full+empty%3; full = 0; } if (empty == 2) { res++; } cout << res << endl; } } // 64 位输出请用 printf("%lld")