养兔子
来源:互联网 发布:nginx 目录跳转 编辑:程序博客网 时间:2024/05/17 05:12
Problem Description
一对成熟的兔子每天能且只能产下一对小兔子,每次都生一公一母,每只小兔子的成熟期是一天。某人领养了一对小兔子,一公一母,请问第N天以后,他将会得到多少对兔子。
Input
测试数据包括多组,每组一行,为整数n(1≤n≤90)。
输入以0结束。
输入以0结束。
Output
对应输出第n天有几对兔子(假设没有兔子死亡现象,而且是一夫一妻制)。
Example Input
120
Example Output
12
Hint
数据类型可以用64位整数:long long
#include<stdio.h>
int main()
{
int n,i;
long long int a[100]={0,1,2};
while(~scanf("%d",&n))
{
if(n==0) break;
for(i=3;i<=n;i++)
a[i]=a[i-1]+a[i-2];
printf("%lld\n",a[n]);
}
return 0;
}
#include<stdio.h>
int main()
{
int n,i;
long long int a[100]={0,1,2};
while(~scanf("%d",&n))
{
if(n==0) break;
for(i=3;i<=n;i++)
a[i]=a[i-1]+a[i-2];
printf("%lld\n",a[n]);
}
return 0;
}
0 1
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 我养的兔子
- 1218养兔子
- 养兔子 (sdut oj)
- E-养兔子
- E-养兔子
- E-养兔子
- 养兔子 递推
- SDUT 养兔子
- Linux基础命令学习:开启8080端口
- 在Mac上安装mysql数据库
- 机器学习门径初窥
- 微信好友在阅读哪些原创文章?
- 博客搬家至博客园http://www.cnblogs.com/SweetBeens/
- 养兔子
- io流,入门例子代码
- 学习记录:python百度贴吧爬虫
- C++指针与地址详解 _0
- Fighting_小银考呀考不过四级
- 为python解释器添加tab补全
- tcp/ip 网络编程 socket
- c++教程(二十一: Polymorphism)
- ccf试题 折点计数