The dinky is a small fish that breeds monogamously and regularly. Within
days of its birth, the male of the species seeks out a mate and bonds with
her for life, never dallying with another. At the end of every month, the
couple issues exactly two offspring, of which one is a boy and the other
a girl. Each of these, in turn, goes off on its amorous quest. Inbreeding
is not uncommon in the confines of a fish tank, so a pair of cousins or
even siblings may end up mating. If there are more females than males,
the excess number who cannot secure a mate will not give birth in that month.
Despite their diminutive dimensions and peaceful nature, a population of
dinkies must not be allowed to multiply ad infinitum. Experts recommend
that one allot at least half a liter of water per dinky fish. Anything
less than that, and the tank is said to be crowded. The solution is
either to buy a larger tank or to catch some dinkies for breakfast.
Given the volume of a tank in liters, the number of male dinkies
currently inhabiting the tank, and the number of females present, you
are to calculate the number of months that can elapse before the tank
becomes crowded. Bear in mind that all couples reproduce simultaneously
at the end of every month. If the input values are such that the tank
is already crowded, the correct answer is 0. If the tank will become
crowded at the end of the first month, the answer is 1.
|