就...dp下去
其實應該滿好想的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include<bits/stdc++.h> using namespace std; #define ull unsigned long long #define ll long long #define ld long double #define PB(x) push_back(x) #define MP(x,y) make_pair(x,y) #define pii pair<int,int> #define vint vector<int> #define rz(x) resize(x) #define X first #define Y second // #define m (l+r)/2 // #define xm (x1+x2)/2 // #define ym (y1+y2)/2 #define DE cout<<"de"<<endl; inline int rit(){ int t=0,k=1; char c; do{ c=getchar(); if(c=='-')k=-1; }while(c<'0'||c>'9'); do{ t=t*10+c-'0'; c=getchar(); }while(c>='0'&&c<='9'); return t*k; }; ll d[45]; int t,n; int main(){ d[1]=1; d[2]=5; d[3]=11; for(int i=4;i<=42;i++){ d[i]=d[i-1]+d[i-2]*4+d[i-3]*2; } cin>>t; while(t--){ cin>>n; cout<<d[n]<<endl; } } |
沒有留言:
張貼留言