分享一道智力题
"""
问题:
300斤土豆,从A到B,距离一共100公里,只有一匹马,
马儿每走一公里吃掉一斤土豆,马儿最多驮100斤,
最多可以送多少斤土豆到B地??
"""
tudou = 300
x = 0 # 土豆消耗量
for i in range(1,101):
# 第一个循环是路程100公里
# 第i次
print('马儿走到第{}公里'.format(i))
if tudou >= 205:
tudou = tudou - 5
x = x + 5
print(x)
print('土豆剩余:{}'.format(tudou))
elif tudou >= 103:
tudou = tudou - 3
x = x + 3
print(x)
print('土豆剩余:{}'.format(tudou))
else:
tudou = tudou - 1
x = x + 1
print(x)
print('土豆剩余:{}'.format(tudou))
正确?答案?
有正确答案,啊?集思广益