My dog has fleas. I suspect that his fleas have fleas. I suspect that his
fleas' fleas have fleas!
Assume that every infested creature (either a dog or a flea) is infested with n
fleas and that k of these are themselves infested (with smaller fleas). At
each smaller size, n stays the same but k decreases by 5 (but never becomes
negative).
For example, suppose that n is 30 and k is originally 7. Then my dog is
infested by 30 fleas of which
7 are infested with tiny fleas. Each of those 7 is infested with 30
tiny fleas of which 2 are infested with 30 miniscule fleas. No miniscule flea is
infested (since 2-5 is not positive). Calculating the entire population we get 23 uninfested fleas +
7 infested fleas + 196 uninfested tiny fleas + 14 infested tiny fleas +
420 minuscule uninfested fleas = 660 fleas of all sizes.
Create a class FleasFleas that contains method population that takes an int n, the
number of full-sized fleas on my dog, and an int k, the number of those that are
themselves infested, and returns the total flea population on my dog. If the
population is more than 10,000,000 return -1.
|