Hundred Horses + Hundred money hundred Chicken + Narcissus number--------"Poor lifting" of three exercises

Source: Internet
Author: User

1 //Hundred -Horse hundred-dollar similar to the question of hundred chicken, poor lift2         3          for(intDM =0;dm<=33;dm++)//the number of horses, the first layer of circulation4             5         {6              for(intZM =0;zm<=50;zm++)//The number of the horses, the second layer of circulation7                 8             {9                  for(intXM = 0; xm<=200;xm++)//the number of ponies, the third cycleTen                      One                 { A                     if(dm+zm+xm==100&&dm*3+zm*2+xm/2.0==100) -                     { -System.out.println ("The number of large horses is" +dm+ "\ T in the number of horses is" +zm+ "\ t Pony number is" +XM); the                     } -                 } -             } -         } +  -  + //Hundred-dollar hundred chicken problem A  at  for(intcock=0;cock<=20;cock++)//the first layer of the Rooster cycle -              -         { -              for(intHen =0;hen<=34;hen++)//The cycle of a hen as a second layer -                  -             { in                 intChick = 100-hen-cock;//calculate the number of chicks -                  to                 if((5*cock + 3*hen +chick/3.0) ==100)//Judging whether it meets the requirements of hundred dollars +                      -                 { the                     //outputs the number of three chickens that meet the requirements *System.out.println ("The number of cocks is" +cock+ ", the number of hens is" +hen+ ", the number of chicks is" +chick); $                 }Panax Notoginseng             } -         } the  +  A //Narcissus number, exhaustive all the three digits of the          +          for(intb = 1;b<=9;b++)//the cycle of the Hundred numbers -              $         { $              for(ints = 0;s<=9;s++)//10-digit loop -                  -             { the                  for(intg = 0;g<=9;g++)//Single -digit loop -                     Wuyi                 { the                     if(B*B*B+S*S*S+G*G*G==B*100+S*10+G)//determine if the condition is met -                     { WuSystem.out.println (b*100+s*10+g); -                          About                     } $                 } -}
View Code

Three exhaustive exercises

Hundred Horses + Hundred money hundred Chicken + Narcissus number--------"Poor lifting" of three exercises

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.