题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
Python3递归解法
def fun(n): if n < 2: return 0 if n == 2: n = 3 count = 0 remainder = n % 3 for i in range(0, n - remainder, 3): count += 1 return count + fun(remainder + count) if __name__ == "__main__": while True: n = int(input()) if n == 0: break print(fun(n))