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

被折叠的 条评论
为什么被折叠?



