牛客华为HJ22_汽水瓶

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
def w_b(a):
result = []
def water_bottle(a,result):
if a==2:
result.append(1)
return
if a==1 or a==0:
return
water,bottle = a//3,a%3
result.append(water)
water_bottle(water+bottle,result)
return result
return sum(water_bottle(a,result))

for line in sys.stdin:
a = line.split()
a = int(a[0])
if a==0: break
else:
result = w_b(a)
print(result)