Hundred money buys hundred chicken--pat province to solve the equation

Source: Internet
Author: User

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?

    1. First set rooster x only, hen y only, chick Z only
    2. Column-Relational: x+y+z=100,5x+3y+z/3=100
    3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.