0002 _ RMB for chicken and 0002 for chicken
Buy chicken for a hundred dollars: a rooster has five yuan, a hen has three yuan, and a chicken has three yuan. buy 100 chickens for 100 yuan, of which a rooster, a hen, the chicks must have them. Ask the rooster, the hen, how many chicks should they buy?
Train of Thought: to set the rooster, hen, and chicken to buy x, y, and z each, the following conditions are met:
X + y + z = 100;
5x + 3y + z/3 = 100;
1 _ author _ = 'prop 93 '2 #/usr/bin/python 3 #-*-coding: UTF-8-*-4 5 # x is the unknown number 6 for y in range (1, 33): 7 for z in range (1, 98 ): 8 x = 100-z-y 9 if (0 <x <20 and x * 5 + y * 3 + z/3 = 100 and z % 3 = 0 ): 10 print (x, y, z) 11 # z is the unknown number12 for x in range (1, 20): 13 for y in range (1, 33 ): 14 z = 100-x-y15 if (z % 3 = 0) and (x * 5 + y * 3 + z/3 = 100 ): 16 s = "gongji: % d; muji: % d; xiaoji: % d" % (x, y, z) 17 print (s) 18 # y is the unknown number19 for x in range (1, 20): 20 for z in range (98 ): 21 y = 100-x-z22 if (x * 5 + y * 3 + z/3 = 100 and z % 3 = 0 and 0 <y <33): 23 print (x, y, z)