We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题目为公鸡5元一只,母鸡3元一只,小鸡1元三只,用100块钱买一百只鸡,问公鸡、母鸡、小鸡各有多少只。
""" 《百钱百鸡》问题
Version: 0.1 Author: 骆昊 """
# 假设公鸡的数量为x,x的取值范围是0到20 for x in range(0, 21): # 假设母鸡的数量为y,y的取值范围是0到33 for y in range(0, 34): z = 100 - x - y if 5 * x + 3 * y + z // 3 == 100 and z % 3 == 0: print(f'公鸡: {x}只, 母鸡: {y}只, 小鸡: {z}只') 该代码穷举方案只出现了3种。实际可打印的方案不至3种,我的代码修改如下 ```python for x in range(1, 21): for y in range(1, 34): z = 100 - 5*x - 3*y if 5*x + y*3 + z == 100 and z > 0: print(f'公鸡: {x}只, 母鸡: {y}只, 小鸡: {z*3}只')
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题目为公鸡5元一只,母鸡3元一只,小鸡1元三只,用100块钱买一百只鸡,问公鸡、母鸡、小鸡各有多少只。
"""
《百钱百鸡》问题
Version: 0.1
Author: 骆昊
"""
The text was updated successfully, but these errors were encountered: