华为机试:汽水瓶
#include <iostream> using namespace std; int main() { // int a, b; // while (cin >> a >> b) { // 注意 while 处理多个 case // cout << a + b << endl; // } int n; while (cin >> n) { if (n == 0) break; int ans = 0; while (n > 2) { ans += n / 3; n = (n / 3) + (n % 3); } if (n == 2) ans += 1; cout << ans << endl; } }