NYOJ 76 Super Step

Source: Internet
Author: User

or a big number.

can refer to the following

http://anglecode.blog.51cto.com/5628271/1640248

http://anglecode.blog.51cto.com/5628271/1640242

http://anglecode.blog.51cto.com/5628271/1631944


Super Stairs

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

      • Input data first contains an integer n (1 <=N<=100), which represents the number of test instances, followed by n rows of data, each line containing an integer m, (1<=m<=40), representing the series of stairs.

      • Output

      • For each test instance, output the number of different walks.

      • Sample input

      • 223 
      • Sample output

      • 12 
#include <iostream> #include <cstring>using namespace Std;int main () {int ans[50][20];int n,m,i,j,k,t; memset (ans,0,sizeof (ans)); Ans[2][0]=1;ans[3][0]=2;cin>>n;while (n--) {cin>>m;if (m<=3) cout<< M-1<<endl;else {for (i=4;i<=m;i++) {for (j=0,k=0;j<20;j++) {ans[i][j]= (ans[i-1][j]+ans[i-2][j]+k)%10;k= (ans[i-1][j]+ans[i-2][j]+k)/10;}} T=19;while (0==ans[m][t]) t--;while (t>=0) Cout<<ans[m][t--];cout<<endl;}} 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.