题目:
现在小瓜想通过台阶走上平台,最底层(小瓜所在的层)编号为 11 ,最顶层编号为 n 。由于小瓜的腿比较短,他一次只能向上走 11 级或者 22 级台阶。小瓜想知道他有多少种方法走上平台,你能帮帮他吗?
input
一个整数n ,其中 2≤n≤25。
output
一行一个整数,表示小瓜上台阶的方案数。
Data Description
对于 12%的数据, 2≤n≤5;
对于 28%的数据, 2≤n≤10;
对于 100%的数据, 2≤n≤25;
Sample 1
Input | Output |
4 | 3 |
Status
#include<iostream>
using namespace std;
int st(int c){
if(c==1){
return 1;
}
if(c==2){
return 1;
}
if(c>2){
return st(c-1)+st(c-2);
}
}
int main(){
int a;
cin>>a;
cout<<st(a);
}