标签:fun 问题 return mat col blog floor exchange rgba
JAVA:
public final int numWaterBottles(int numBottles, int numExchange) { int re = numBottles, empty = numBottles; while (empty >= numExchange) { int newBeer = empty / numExchange; re += newBeer; empty = empty % numExchange + newBeer; } return re; }
JS:
/** * @param {number} numBottles * @param {number} numExchange * @return {number} */ var numWaterBottles = function (numBottles, numExchange) { let re = numBottles, empty = numBottles; while (empty >= numExchange) { let newBeer = Math.floor(empty / numExchange); re += newBeer; empty = empty % numExchange + newBeer; } return re; };
标签:fun 问题 return mat col blog floor exchange rgba
原文地址:https://www.cnblogs.com/niuyourou/p/14749106.html