题解 | #汽水瓶#

汽水瓶

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

let line;
while(line = readline()) {
    if(parseInt(line) !== 0) {
// 方法1:计算每轮结果相加
//         let max = 0;
//         let count = parseInt(line);
//         while(count > 2) {
//             max += Math.floor(count / 3);
//             count = Math.floor(count / 3 + count % 3);
//         }
//         max += count === 2 ? 1 : 0;
//         console.log(max);
// 方法二,每两瓶就能换一瓶,剩一瓶的时候喝不了
        console.log(Math.floor(parseInt(line) / 2));
    }
}


全部评论

相关推荐

真得找个班上:真是白嫖学生劳动力脸都不要了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务