the
Poke the puzzle here.
Obviously the minimum number of steps is that each grid just goes once.
Enumerate the starting positions and consider how you can get there.
A great deal of discussion can be found that we need only know two things on it.
One is Di D_i, which represents the number of scenarios in the upper-right corner of the 2∗i 2*i grid, traversing all the grids once and stopping below the momentum position.
Apparently Di=di−1∗2 d_i=d_{i-1}*2.
There is also a fi f_i that represents the number of scenarios in the upper-right corner of the 2∗i 2*i grid, traversing all the squares.
The classification discussion may be:
fi=fi−1∗2+ (di−1+fi−2∗2) ∗2 f_i=f_{i-1}*2+ (d_{i-1}+f_{i-2}*2) *2
And then it's okay.
#include <cstdio> #include <algorithm> using namespace std; const int MAXN=20005,
mod=1000000007;
typedef long Long LL;
int _test,n;
LL F[maxn],d[maxn],ans;
int main () {f[1]=d[1]=1;
for (int i=2;i<=10000;i++) {d[i]=d[i-1]*2%mod;
F[i]= (f[i-1]*2%mod+ (d[i-1]+ i==2?1: (f[i-2]*2%mod))%mod*2%mod)%mod;
} scanf ("%d", &_test);
while (_test--) {scanf ("%d", &n);
ans=0; for (int i=1;i<=n;i++) {if (i==1| |
I==n) {ans= (ans+f[n])%mod; continue;}
Ans= (ans+ (f[i-1]*d[n-i]%mod+d[i-1]*f[n-i]%mod)%mod*4%mod)%mod;
printf ("%lld\n", ans*2%mod);
return 0; }