Files
2025PY/day12/01-作业.py
2025-05-22 16:50:44 +08:00

15 lines
520 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 鸡兔同笼鸡兔同笼35个头94只脚用 鸡有多少只兔有多少只?
# 通过循环去不断的进行组合(鸡和兔子区间范围0--35)
# 抓住限制条件(35个头94只脚用)
for i in range(0,36): # 通过循环去不断的进行组合 鸡
for j in range(0,36): # 通过循环去不断的进行组合 兔
if (i + j == 35) and (i * 2 + j * 4 == 94):
print(f'鸡有{i}只,兔子有{j}')