养兔子
来源:互联网 发布:蓝鸽集团知乎 编辑:程序博客网 时间:2024/04/28 15:24
Problem Description
一对成熟的兔子每天能且只能产下一对小兔子,每次都生一公一母,每只小兔子的成熟期是一天。某人领养了一对小兔子,一公一母,请问第N天以后,他将会得到多少对兔子。
Input
测试数据包括多组,每组一行,为整数n(1≤n≤90)。
输入以0结束。
输入以0结束。
Output
对应输出第n天有几对兔子(假设没有兔子死亡现象,而且是一夫一妻制)。
Example Input
120
Example Output
12
Hint
数据类型可以用64位整数:long long
这题跟母牛的故事一个道理。。。还是换了个问法
01
#include<stdio.h>
02
int
main()
03
{
04
int
i, n;
05
long
long
a[91];
06
while
(
scanf
(
"%d"
, &n) != EOF)
07
{
08
a[1] = 1;
09
a[2] = 2;
10
if
(n == 0)
break
;
11
for
(i = 3; i <= n; i++)
12
a[i] = a[i - 1] + a[i - 2];
13
printf
(
"%lld\n"
, a[n]);
14
}
15
return
0;
16
}
17
01
#include<stdio.h>
02
int
main()
03
{
04
int
i, n;
05
long
long
a[91];
06
while
(
scanf
(
"%d"
, &n) != EOF)
07
{
08
a[1] = 1;
09
a[2] = 2;
10
if
(n == 0)
break
;
11
for
(i = 3; i <= n; i++)
12
a[i] = a[i - 1] + a[i - 2];
13
printf
(
"%lld\n"
, a[n]);
14
}
15
return
0;
16
}
17
0 0
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 养兔子
- 我养的兔子
- 1218养兔子
- 养兔子 (sdut oj)
- E-养兔子
- E-养兔子
- E-养兔子
- 养兔子 递推
- SDUT 养兔子
- POJ 1269 Intersecting Lines (判断线段之间关系)
- 下压(LIFO栈)_API
- 【JZOJ 4937】与运算
- 煤球数目
- 将TensorFlow的网络导出为单个文件
- 养兔子
- 从用户的视角看待网页设计(一)
- linux下安装jdk1.8
- android 保存图片到手机相册,并通知相册刷新
- Go-struct嵌套初始化与赋值
- hihocoder 1388 2016北京网络赛1006 Periodic Signal(卡精度的FFT)
- html canvas元素 时钟
- 58.贝赛尔曲线初步(三) - 实现添加至购物车的运动轨迹
- ESP8266 机智云 开发环境搭建(一)安装Linux系统