文章

130

粉丝

0

获赞

191

访问

13.3k

头像
N阶楼梯上楼问题 题解:
P1413 华中科技大学/中国矿业大学机试题
发布于2026年2月9日 09:56
阅读数 111

//递推
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin >> n){
		long long a[90];
		a[1] = 1;
		a[2] = 2;
		for(int i=3;i<=n;i++)
			a[i] = a[i-1] + a[i-2];
		cout << a[n] << endl;
	}	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发