zoukankan      html  css  js  c++  java
  • nyoj 76 超级台阶

     

    超级台阶

    时间限制:1000 ms  |  内存限制:65535 KB
    难度:3
     
    描述

    有一楼梯共m级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第m级,共有多少走法?

    注:规定从一级到一级有0种走法。

     
    输入
    输入数据首先包含一个整数n(1<=n<=100),表示测试实例的个数,然后是n行数据,每行包含一个整数m,(1<=m<=40), 表示楼梯的级数。
    输出
    对于每个测试实例,请输出不同走法的数量。
    样例输入
    2
    2
    3
    样例输出
    1
    2
    来源
    [苗栋栋]原创
    上传者
    苗栋栋
    很简单的递推题目
    错了很多次 原来a【1】=0 忘了这个
    View Code
     1  
     2 /*********************************
     3 /   Problem:
     4 /   Algorithm:
     5 /   Language:   C++
     6 /   Compiler:   MinGW
     7 /   Date:       12/08/08
     8 /
     9 /   Copyright (C) wujianwei
    10 /   All rights reserved.
    11 ********************************/
    12 
    13 #include <iostream>
    14 #include <cstdio>
    15 #include <cstring>
    16 #include <cmath>
    17 #include <vector>
    18 #include <cstring>
    19 #include <queue>
    20 #include <stack>
    21 #include <algorithm>
    22 #include <set>
    23 
    24 using namespace std;
    25 
    26 #define INF 0x7fffffff
    27 #define EPS 1e-12
    28 #define MOD 1000000007
    29 #define PI 3.141592653579798
    30 #define N 100005
    31 const int MAX=1<<28;
    32 typedef long long LL;
    33 //typedef __int64 INT
    34 int a[41]={0,0,1,2};
    35 int main()
    36 {
    37     int T;
    38     for(int i=4;i<41;i++) a[i]=a[i-1]+a[i-2];
    39     scanf("%d",&T);
    40     while(T--)
    41     {
    42         int n;
    43         scanf("%d",&n);
    44         printf("%d\n",a[n]);
    45         //cout<<a[n]<<endl;
    46     }
    47     return 0;
    48 }
    49         
  • 相关阅读:
    带着萌新看springboot源码
    学习springboot
    第一次来博客园
    第2章 排版样式
    第1章 Bootstrap介绍
    tab左右箭头切换
    $()下的常用方法2
    前端性能优化----yahoo前端性能团队总结的35条黄金定律
    tab
    $()下的常用方法
  • 原文地址:https://www.cnblogs.com/wujianwei/p/2636991.html
Copyright © 2011-2022 走看看