方程简化 | HJ72 百钱买百鸡
# 最优解 for num in range(4): print(f'{4*num} {25-7*num} {75+3*num}') # 我的代码 def func(): input() m = 100 for z in range(0, 99, 3): for x in range(0, 20): # 公鸡最多20只 y = 100 -z - x # 母鸡数量 if 5*x + 3*y == 100 - z//3 and y >= 0: print(f'{x} {y} {z}') func()
用时:30min
#方程#华为笔试刷题 文章被收录于专栏
高质量题: 1~40:HJ16,HJ22,HJ24,HJ26,HJ27,HJ28,HJ35,HJ37,HJ39; 40~80:HJ41,HJ42,HJ43,HJ44,HJ48,HJ50,HJ52,HJ53,HJ57,HJ61,HJ63,HJ64,HJ70,HJ71,HJ74,HJ77; 80~108:HJ82,HJ85,HJ88,HJ89,HJ93,HJ95,HJ98,HJ103,HJ107