The question is this:
Rooster 5 Text Money One, hen 3 text money A, chicken three only 1 money, how to buy, 100 article just buy 100?
- First set rooster x only, hen y only, chick Z only
- Column-Relational: x+y+z=100,5x+3y+z/3=100
- concluded: 0<x<20,0<y<33,0<z<100
Good! What a beautiful job! All the information you have extracted is complete! Then turn it into a Python language!
You must know: Computer computing power is much faster than people, people calculate once, maybe the computer has been calculated thousands of times, this is low, right! This is the problem of the problem solving principle : The use of computer computing speed to traverse all possible, the results of the establishment of the output can be!
The problem solving process is as follows:
For x in range (1,20): For y in range (1,33): for z in range (1,100): if x+y+z==100: if 5*x+3*y+z/3==100:< C12/>print (' Rooster for; ', X, ' Hen for: ', y, ' chick for: ', z)
This uses the for loop to traverse ,if for conditional judgment, range function to represent the range of variables , Pro! Do you understand me?
Answers revealed:
Cocks for: 4 hens for: 18 Chicks for: 78
Cocks for: 8 hens for: 11 Chicks for: 81
Cocks for: 12 Hens for: 4 Chicks for: 84
Life-Related:
Purchase, Stock
you are welcome to ask questions and questions about my blog content! Thanks
Hundred money buys hundred chicken--pat province to solve the equation