Fibonacci’s Rabbits
From http://ecoocs.org/contests/ecoo_2006.pdf
The well known Fibonacci sequence 1,1,2,3,5,8,13,21,… is based on the proposition that, given that any pair of rabbits will produce a new pair of rabbits every month for ever, except in the first month after their birth. The sequence gives the number of pairs of rabbits that there would be in any given month.
That is:
starting with 1 newborn pair in month one,
which would still be 1 pair of rabbits in month two,
which would be 2 pairs in month 3 (since this pair would produce a new pair in month 3),
there would be 3 pairs in month 4 (since the first pair would produce a new pair)
there would be 5 pairs in month 5 (since the first two pairs would produce a new pair…etc.)
But suppose, that, instead of living forever, and reproducing endlessly, each pair of rabbits would only live for 5 months, and therefore only produce 3 new pairs before they died. The sequence then would run: 1,1,2,3,5,6,10,14,…
And if each pair would live for only 3 months, the sequence would become: 1,1,2,1,2,1,2,…
DATA11.txt (DATA12 for the second try) contains 5 lines of two positive integers, A and B.
The integer A represents the number of months each pair of rabbits lives, 2 < A < 101. The integer B represents the number of months that have passed when the count of the number of pairs of rabbits occurs. A and B will have values such that the number of pairs of rabbits will never exceed 999 999 999.
Output should be on a cleared screen or window, and will state the number of rabbit pairs in each of the 5 cases. Output should appear as in the example below.
Sample Input: Sample Output
5 10 in problem #1 there are 30 rabbit pair(s)
30 30 in problem #2 there are 832040 rabbit pair(s)
12 40 in problem #3 there are 95539192 rabbit pair(s)
4 40 in problem #4 there are 65657 rabbit pair(s)
6 49 in problem #5 there are 740444619 rabbit pair(s)