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