[Recursive] HDU6146 Pokémon go__ Other

Source: Internet
Author: User
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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.