NYOJ 76 Super Step

Source: Internet
Author: User

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

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.