5 6 2 [sample output]
CodePudding user response:
Go the wrong area brothersCodePudding user response:
Go the wrong area brothersCodePudding user response:
23 # 19 + x * * y + z=235
If __name__=="__main__ ':
Total=235 # take common multiple of x and y (such as 437) will have more than one result
Unit_x=19
23 unit_y=
List_initial=[]
For the x in the range (total//unit_x + 1) :
For y in range (total//unit_y + 1) :
If x + y * * unit_x unit_y & lt;=total:
Z=total - x * unit_x - y * unit_y
List_initial. Append ((x, y, z))
# print (f 'x * * {unit_y} {unit_x} + y + z={total} : x={x}, y={} y, z={} z')
List_sortz=sorted (list_initial, key=lambda x: x [2]) # sort by z
Min_z=list_sortz [0] [2]
For the row in list_sortz:
If min_z & lt; The row [2] :
Break
Print (row)
# print (f 'x={row [0]}, y={row [1]}, z={row [2]}')