题解 | #汽水瓶#

汽水瓶

https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int initNum;
    int result = 0;
    while(cin >> initNum){
        int result = 0;
        int emptyBottol = initNum;
        while(emptyBottol >= 3)
        {
            result += emptyBottol/3;
            emptyBottol = emptyBottol%3 + emptyBottol/3;
        }
	  // 只有剩余两瓶才有机会靠借多喝一瓶
        if(emptyBottol == 2)result++;
        if(initNum != 0)cout<< result << endl;
    }

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

求个付费实习岗位:这种就是吃满时代红利又没啥技术水平,只能靠压力学生彰显优越感的老登,别太在意了
点赞 评论 收藏
分享
12-05 18:09
已编辑
广东药科大学 后端工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务