当N=1、2、3时可以直接求出F[N]。当N>3时可得递推关系F[N]=F[N-1]+2*F[N-2];
#include <stdio.h>
__int64 a[51] = {0, 3, 6, 6};
int main(){
int n;
for(int i = 4; i != 51; ++i)
a[i] = a[i - 1] + a[i - 2] * 2;
while(scanf("%d", &n) == 1)
printf("%I64d\n", a[n]);
return 0;
}HDU2045 不容易系列之(3)—— LELE的RPG难题,布布扣,bubuko.com
HDU2045 不容易系列之(3)—— LELE的RPG难题
原文:http://blog.csdn.net/chang_mu/article/details/21290837