解题思路:
注意事项:
参考代码:
def calculate_max_sodas(n):
if n < 2:
return 0
total_sodas = 0
remaining_bottles = 0
while n >= 3 :
sodas_from_bottles = n // 3
total_sodas += sodas_from_bottles
remaining_bottles = n % 3 + sodas_from_bottles
n = remaining_bottles
if remaining_bottles == 2:
total_sodas += 1
return total_sodas
while True:
n = int(input())
if n == 0:
break
max_sodas = calculate_max_sodas(n)
print(max_sodas)
0.0分
2 人评分
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:324 |
点我有惊喜!你懂得!浏览:1238 |
C语言程序设计教程(第三版)课后习题8.1 (Java代码)浏览:781 |
大神老白 (C语言代码)浏览:611 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:968 |
简单的a+b (C++语言代码)浏览:859 |
程序员的表白 (C语言代码)浏览:667 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:703 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:691 |
用筛法求之N内的素数。 (C语言代码)浏览:806 |