题目:http://acm.hdu.edu.cn/showproblem.php?pid=2045
思路:明显是找出递归的方程。用高中的排列祝贺算
Code:
#include <cstdio> #include <algorithm> #include <iostream> using namespace std; int main() { int n; long long a[125]; a[1]=3; a[2]=6; a[3]=6; for (int i=4;i<=65;i++) { a[i]=a[i-1]+a[i-2]*2; } while (cin>>n) cout<<a[n]<<endl; return 0; }