超级楼梯
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 56952 Accepted Submission(s): 28952
Problem Description
有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?
Input
输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。
Output
对于每个测试实例,请输出不同走法的数量
Sample Input
2 2 3
Sample Output
1 2
Author
lcy
Source
2005实验班短学期考试
Recommend
lcy | We have carefully selected several similar problems for you: 2044 2045 2046 2018 2050
View Code
Problem : 2041 ( 超级楼梯 ) Judge Status : Accepted
RunId : 20129447 Language : C Author : 837274600
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
RunId : 20129447 Language : C Author : 837274600
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
#include<stdio.h> #include<string.h> #include<math.h> int main() {int n, f[50] = {1,1};for (int i = 2; i <= 40; i++){f[i] = f[i - 1] + f[i - 2];}scanf("%d", &n);{while (n--){int a;scanf("%d", &a);printf("%d\n", f[a-1]);}}return 0; }