题解 | #汽水瓶#
汽水瓶
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));
    }
}

 查看4道真题和解析
查看4道真题和解析