A - 养兔子
Description
一对成熟的兔子每月能且只能产下一对小兔子,每次都生一公一母,每只小兔子的成熟期是一个月,而成熟后的第二个月才开始生小兔。某人领养了一对小兔子,一公一母,请问第N个月以后,他将会得到多少对兔子。
Input
测试数据包括多组,每组一行,为整数n(1≤n≤90)。 输入以0结束。
Output
对应输出第n个月有几对兔子(假设没有兔子死亡现象,而且是一夫一妻制)。
Sample Input
1
2
0
Sample Output
1
2
Hint
数据类型可以用64位整数:long long
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[91]={0,1,2,0};
ll yang(ll n)
{
if(a[n]>0)
return a[n];
a[n]=yang(n-1)+yang(n-2);
return a[n];
}
int main()
{
ll n;
while(cin>>n&&n)
{
ll ans=yang(n);
cout<