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