HDU - 2041 超级楼梯
2016-09-21 21:19
197 查看
题目:
Description
有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?
Input
输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。
Output
对于每个测试实例,请输出不同走法的数量
Sample Input
Sample Output
斐波那契
代码:
Description
有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?
Input
输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。
Output
对于每个测试实例,请输出不同走法的数量
Sample Input
2 2 3
Sample Output
1 2
斐波那契
代码:
#include<iostream> #include<stdio.h> using namespace std; long long list[50]; int main() { list[1] = 1; list[2] = 2; for (int i = 3; i < 50; i++)list[i] = list[i - 1] + list[i - 2]; int n, a; cin >> n; while (n--) { cin >> a; cout << list[a-1] << endl; } return 0; }
相关文章推荐
- HDU 2044 一只小蜜蜂... 斐波那契问题 2041 超级楼梯
- HDU:2041 超级楼梯(规律)
- HDU 2041 超级楼梯
- HDU 2041:超级楼梯
- HDU(2041) (超级楼梯)
- HDU 2044 一只小蜜蜂... HDU 2041 超级楼梯
- HDU 2041--超级楼梯题解(递推求解专题)
- 超级楼梯 HDU - 2041
- hdu 2041:超级楼梯(水题,递归)
- hdu--2041 超级楼梯
- HDU 2041 超级楼梯
- HDU 2041 超级楼梯
- HDU 2041 超级楼梯
- HDU 2041 超级楼梯
- hdu 2041 超级楼梯
- HDU-2041 - 超级楼梯 - 斐波那契数列
- hdu 2041 超级楼梯(简单dp)
- 超级楼梯 【hdu-2041】【递推】
- hdu 水题 2041超级楼梯
- 超级楼梯 HDU-2041