step1_入门_ACM趣味题 超级楼梯

http://acm.hdu.edu.cn/showproblem.php?pid=2041

有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?

#include
#include 
using namespace std;
int a[45];
int main(){
	std::ios::sync_with_stdio(false);
 	std::cin.tie(0); 
 	int T;cin>>T; 
 	while(T--){
 		int n;
 		cin>>n;
 		a[1]=1;
 		a[2]=1;
 		for(int i=3;i<=n;i++){
 			a[i]=a[i-1]+a[i-2];
		 }
		 cout<

 

你可能感兴趣的:(2018年为准备CCF,CSP的第二遍刷题)