题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include <stdio.h> int getDrinkB(int numAll) { int drinkCount = 0; int leftNum = numAll; int currentDrink = 0; while(leftNum >= 3) { currentDrink = leftNum / 3; drinkCount += currentDrink; leftNum = currentDrink + leftNum % 3; currentDrink = 0; } if(leftNum == 2) drinkCount++; return drinkCount; } int main() { int num = 0; int drinkCount = 0; int ret = scanf("%d",&num); while(0 != num && EOF != ret) { printf("%d\n",getDrinkB(num)); ret = scanf("%d",&num); } return 0; }