3100.cpp (333B)
1 class Solution { 2 public: 3 int maxBottlesDrunk(int numBottles, int numExchange) const { 4 int res = 0; 5 while (numBottles >= numExchange) { 6 numBottles -= numExchange; 7 res += numExchange; 8 numBottles++; 9 numExchange++; 10 } 11 return res + numBottles; 12 } 13 };