彼岸
#include<iostream> using namespace std; long long a[44]; int main() { a[1] = 3, a[2] = 9; for(int i=3; i<40; i++) a[i] = 2*a[i-1] + a[i-2]; int c; cin>>c; while(c--) { int n; cin>>n; cout<<a[n]<<endl; } return 0; }
彼岸
#include<iostream> using namespace std; long long a[44]; int main() { a[1] = 3, a[2] = 9; for(int i=3; i<40; i++) a[i] = 2*a[i-1] + a[i-2]; int c; cin>>c; while(c--) { int n; cin>>n; cout<<a[n]<<endl; } return 0; }