离谱思路

有点离谱的思路,恰好是2个瓶子最终能换一瓶,所以直接整除2即可,但标准解决方案应该是使用递归的思路

import sys
data = sys.stdin
for x in data:
    x = int(x.strip())
    if x != 0:
        print(int(x // 2))

递归思路

import sys

def f(n):
    if n == 0: return 0
    if n == 1: return 0
    if n >=2: return f(n-2) + 1


if __name__ == '__main__':
    data = sys.stdin
    for x in data:
        x = int(x.strip())
        if x != 0:
            print(f(x))