C-Super Staircase

Source: Internet
Author: User

Description

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 level or two, to go to the grade m, how many kinds of methods?

Input

The input data first contains an integer n, which represents the number of test instances, followed by n rows of data, each containing an integer M (1<=m<=40) representing the series of stairs.

Output

For each test instance, please output the number of different methods.

Sample Input

223

Sample Output

12
#include <cstdio>#include<cstring>#include<iostream>#include<stdlib.h>#include<vector>#include<queue>#include<cmath>using namespacestd;#defineMAXN 100#defineOO 0x3f3f3f#definePI 3.1415926535897932intN;intK;Long LongDP[MAXN];voidinit () { for(intI=4; i<=maxn; i++) Dp[i]= dp[i-2] + dp[i-1];}intMain () {intt,m; scanf ("%d",&t);  while(t--) {scanf ("%d",&m); dp[1] =1; dp[2] =1; dp[3] =2;        Init (); printf ("%i64d\n", Dp[m]); }    return 0;}

C-Super Staircase

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.