主题:国际大学生程序设计竞赛中的一个简单的问题
Problem A
Rabbit (兔子问题)
Standard Input /Standard out put
The rabbits have powerful reproduction ability .One pair of adult rabbits can give birth to one pair of kid rabbits every month. And after m months,the kid rabbits can become adult rabbits.
As we all know ,when m=2,the sequence of the number of pairs of rabbits in each month is called Fibonacci sequence .But when m<>2,the problem seems not so simple .You job is to calculate after d months ,how many pairs of the rabbits are there if there is exactly one pair of adult rabbits initially.you may assume that none of the rabbits dies in this period.
Input :
The input may have multiple test cases . In each test case ,there is one line having two integers m(1<=m<=10),d(1<=d<=100),m is the number of months after which kid rabbits can number of pairs of rabbits. The input will be terminated by m=d=0.
Output:
You must print the number of pairs of rabbits after d months .one integer per line .
希望有兴趣的同学一起讨论一下
Rabbit (兔子问题)
Standard Input /Standard out put
The rabbits have powerful reproduction ability .One pair of adult rabbits can give birth to one pair of kid rabbits every month. And after m months,the kid rabbits can become adult rabbits.
As we all know ,when m=2,the sequence of the number of pairs of rabbits in each month is called Fibonacci sequence .But when m<>2,the problem seems not so simple .You job is to calculate after d months ,how many pairs of the rabbits are there if there is exactly one pair of adult rabbits initially.you may assume that none of the rabbits dies in this period.
Input :
The input may have multiple test cases . In each test case ,there is one line having two integers m(1<=m<=10),d(1<=d<=100),m is the number of months after which kid rabbits can number of pairs of rabbits. The input will be terminated by m=d=0.
Output:
You must print the number of pairs of rabbits after d months .one integer per line .
希望有兴趣的同学一起讨论一下