#include<iostream> using namespace std; int main() { int n,f[40],m; f[1]=1;f[2]=3; for(int i=3;i<=40;i++) { f[i]=f[i-1]+2*f[i-2]; } cin>>n; for(int j=0;j<n;j++) { cin>>m; cout<<f[m]<<endl; } return 0; }
转载于:https://www.cnblogs.com/ycxgmail/archive/2012/11/10/2763579.html