不容易系列之(3)—— LELE的RPG难题

 

 

 

 

#include <cstdio>

long long int memo[55];

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

int main()
{
	long long int n;
	while(scanf("%lld", &n) != EOF)
	{
		printf("%lld\n", f(n));
	}
	
	return 0;
}

  

posted @ 2019-08-02 14:42  青衫客36  阅读(204)  评论(0编辑  收藏  举报