养兔子
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
一对成熟的兔子每天能且只能产下一对小兔子,每次都生一公一母,每只小兔子的成熟期是一天。某人领养了一对小兔子,一公一母,请问第N天以后,他将会得到多少对兔子。
Input
测试数据包括多组,每组一行,为整数n(1≤n≤90)。
输入以0结束。
输入以0结束。
Output
对应输出第n天有几对兔子(假设没有兔子死亡现象,而且是一夫一妻制)。
Example Input
1 2 0
Example Output
1 2
Hint
数据类型可以用64位整数:long long
Author
majia
参考代码
#include<stdio.h>
int main()
{
int i,n;
long long a[90];
a[0] = 1;
a[1] = 2;
while(~scanf("%d",&n)&&n)
{
for( i = 2; i < n; i++ )
{
a[i] = a[i-1] + a[i-2];
}
printf("%lld\n",a[n-1]);
}
return 0;
}