Super Step time limit:MS | Memory limit:65535 KB Difficulty:3
-
Describe
-
There is a total of a staircase of M-class, just at the beginning of you in the first level, if you can only step up one or two levels, to go to the first Class m, how many methods?
Note: There are 0 ways to go from one level to the next.
-
Input
-
The input data first contains an integer n (1<=n<=100), representing the number of test instances, followed by n rows of data, each line containing an integer m, (1<=m<=40), representing the stair progression.
-
Output
-
For each test instance, output the number of different methods to be run.
-
Sample input
-
223
-
Sample output
-
12
#include <stdio.h>int main () {int n,m,j,i,l,sum;int a[44];scanf ("%d", &n), while (n--) {a[1]=0;a[2]=1;a[3]=2; scanf ("%d", &m); for (i=4;i<=m;i++) {a[i]=a[i-2]+a[i-1];} printf ("%d\n", A[m]);} return 0;}
NYOJ 76 Super Step