标签:递归
#include <cstdio>
#include <iostream>
using namespace std;
long long a[55] = {0,3,6};
long long b[55] = {0,0,0,6};
long long int fun(int x);
long long int funa(int x);
long long int fun(int x){
if(a[x]) return a[x];
return a[x] = funa(x-1) * 2 + fun(x-1);
}
long long int funa(int x){
if(b[x]) return b[x];
if(x <= 2) return 0;
return b[x] = fun(x-1);
}
int main(){
int n;
fun(50);
while(cin >> n){
printf("%I64d\n",a[n]);
}
return 0;
}版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:递归
原文地址:http://blog.csdn.net/qq_24667639/article/details/46830289