百钱买鸡

百钱买百鸡问题:公鸡五文钱一只,母鸡三文钱一只,小鸡三只一文钱,用 100 文钱买 100

只鸡,要求三种鸡都要有.请问公鸡、母鸡、小鸡各买多少只?

for x in range(1,100//5):
    for y in range(1,100//3):
        for z in range(100):
            if x + y + z == 100 and 5*x + 3*y + z/3 ==100 :
                print(x,y,z)

 

posted @ 2022-07-24 10:06  colin_7  阅读(46)  评论(0编辑  收藏  举报