Classic algorithm details (6) Fisherman fishing

Source: Internet
Author: User

A, B, C, D, E5 fishermen at night to fish together, each in the river side of the bushes rest. When Sun is, fisherman a first woke up, he divided the fish into 5 parts, and threw the extra one back into the river and took one of his own home. Fisherman B Second Wake up, also will be divided into 5 parts of the fish, throw away the extra one, take one of their own, and then the next three also according to the same method to divide the fish, asked 5 fishermen at least how many fish in partnership.

1#include <iostream>2 3 using namespacestd;4 5 6  intIsinteger (floati) {//used to determine whether an integer7     if(I-(int) i = =0) {8         return 1;9     }Ten     Else { One         return 0; A     } - } -  the //push from the back to the front, initialize count means E wakes up to see the number of bars, so after four cycles is a see the number of bars, - intFish_count () { -     floatcount; -      for(intn =1; N <10000; n++) { +Count =5* n +1; -         intFlag =1; +          for(inti =0; I <4; i++) { ACount = Count *5/4+1.0; at             if(!Isinteger (count)) {             -Flag =0; -                  Break; -             } -         } -         if(flag) { in             return(int) count; -         } to     } +     return-1; - } the  * intMainintargcChar*argv[]) { $cout <<Fish_count ();Panax Notoginseng GetChar (); -     return 0; the}

Classic algorithm details (6) Fisherman fishing

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.