My 3g Interview Questions (Baima bailiang)

Source: Internet
Author: User

 

 

Question: 100 horses carry 100 yuan of grain. A horse carries three bears, and a middle horse carries two bears. Two ponies carry one load. Program and output all conditions that meet the conditions.

What is this question? Relatively speaking, it is really simple and unexpected.

My analysis:

The maximum number of horses is 20, and the maximum number of horses is 33. This is just a mathematical inequality.

Public class text3g
{
Public static void main (string [] ARGs)
{
Int I, j; // I indicates the horse, and J indicates the horse
For (I = 0; I <= 20; I ++)
For (j = 0; j <= 33; j ++)
{
If (100-i-j) % 2! = 0)
Continue;
If (3 * I + 2 * j + (100-i-j)/2 = 100)
System. Out. println ("Big Horse is" + I + "middle horse is" + J + "small

Horse is "+ (100-i-j ));
}
}
}

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.