题目:http://acm.hdu.edu.cn/showproblem.php?pid=2190
递推,找规律不难.
#include <iostream> using namespace std; int main() { int T; __int64 d[31] = {0, 1, 3, 5}; for (int i = 4; i < 31; i++) d[i] = d[i-1] + 2*d[i-2]; cin>>T; for(int i=0;i<T;i++) { int n; cin>>n; cout<<d[n]<<endl; } return 0; }