超级楼梯

#include <cstdio>

int memo[45];

int f(int n)
{
	memo[2] = 1;
	memo[3] = 2;
	
	for(int i = 4; i <= n; ++ i)
	{
		memo[i] = memo[i - 1] + memo[i - 2];
	}
	return memo[n];
}

int main()
{
	int n, m;
	scanf("%d", &n);
	
	while(n --)
	{
		scanf("%d", &m);
		printf("%d\n", f(m));
	}
	
	return 0;
}

  

posted @ 2019-08-01 17:11  青衫客36  阅读(91)  评论(0编辑  收藏  举报