题解 | #百钱买百鸡问题#

百钱买百鸡问题

https://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b

'''
# 直接遍历查找:x 鸡翁,最多20只;y 鸡母,最多33只;z 鸡稚,最多100.
n=int(input())
for x in range(0,21):
    for y in range(0,33):
        for z in range(0,101):
            if 5*x+3*y+z/3==100 and x+y+z==100:
                print(x,y,z)
'''
'''
# 方程推导:x=4*i  y=25-7i  z=100-x-y
x>=0-----> i>=0
y>=0-----> i<4
故 0<=i<4
'''
while True:
    try:
        n=int(input())
        for i in range(0,4):
            x=4*i
            y=25-7*i
            z=100-x-y
            print(x,y,z)
    except:
        break

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务