#P5775. [AHOI2006] 斐波卡契的兔子
[AHOI2006] 斐波卡契的兔子
Problem Description
Kaka has started raising rabbits. His mother bought him a pair of newborn rabbits. Kaka learned that the rabbits reproduce as follows: a pair of rabbits will give birth for the first time one month after birth, producing pairs of rabbits. Then, two months after birth, they will produce pairs of rabbits. In the third month and every month after that, they will reproduce pairs of rabbits each month (). We know from the Fibonacci sequence that rabbits can reproduce very quickly. However, Kaka has as many good friends as rabbits, so he wants to have pairs of rabbits after months to give them to his friends. Can his wish come true?
[Task] Write a program that reads the input information from the input file; computes how many pairs of rabbits Kaka will have after months, denoted as ; computes the minimum number of pairs of rabbits his mother must buy at the beginning so that Kaka will have at least pairs of rabbits after months, denoted as ; and outputs the results to the output file.
Input Format
The first line of the input file contains four positive integers: , , , and . The second line contains only one positive integer . Their meanings are described above.
Output Format
Output two lines. The first line contains an integer , and the second line contains an integer .
0 1 1 10
10000
89
113
Hint
Constraints: , , .
Translated by ChatGPT 5