编程 用python计算出 瓶子2元一个 4个瓶盖换一个瓶子 100元有多
答案:2 悬赏:70 手机版
解决时间 2021-03-07 10:09
- 提问者网友:酱爆肉
- 2021-03-06 22:54
少个瓶子
最佳答案
- 五星知识达人网友:怙棘
- 2021-03-06 23:09
def calc(n) :
total = n / 2
ping = total
gai = total
if total == 0:
return 0
else:
while ping / 2 > 0 or gai / 4 > 0:
if ping / 2 > 0:
tmp = ping/2
total = total + tmp
gai = gai + tmp
ping = ping % 2
ping += tmp
elif gai / 4 > 0 :
tmp = gai / 4
total = total + tmp
ping = ping + tmp
gai = gai % 4
gai += tmp
return total
print calc(100)>>>
195
total = n / 2
ping = total
gai = total
if total == 0:
return 0
else:
while ping / 2 > 0 or gai / 4 > 0:
if ping / 2 > 0:
tmp = ping/2
total = total + tmp
gai = gai + tmp
ping = ping % 2
ping += tmp
elif gai / 4 > 0 :
tmp = gai / 4
total = total + tmp
ping = ping + tmp
gai = gai % 4
gai += tmp
return total
print calc(100)>>>
195
全部回答
- 1楼网友:笑迎怀羞
- 2021-03-06 23:28
我。。知。。道
加。。我。。私。。聊
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯