The meaning of problems, only black and white of a matrix
The picture shows the probability of satisfying said each square up and down four directions only one color squares and squares the same color map of the current
answer
By meter
-0 | 2*1 | 2*2 | 2*3 | 2*5 | 2*8 | 2*13 |
-1 | 2*2 | 2*3 | 2*4 | 2*6 | 2*9 | 2*14 |
-2 | 2*3 | 2*4 | 2*5 | 2*7 | 2*10 | 2*15 |
-4 | 2*5 | 2*6 | 2*7 | 2*9 | 2*11 | |
-7 | 2*8 | 2*9 | 2*10 | 2*12 | 2*15 | |
-12 | 2*13 | 2*14 | 2*15 | 2*17 |
We found each row meet $ f [i] = f [i-1] + f [i-2] -c $ form
$ C $ conform $ abs (c [i]) = abs (c [i-1]) + abs (c [i 2-]) + 1 $ the form
The first two columns in line with $ f [i] = f [i-1] + f [i-2] -c $ form
Recurrence
#include<bits/stdc++.h> using namespace std; #define ll long long #define A 1111111 const ll mod=1e9+7; ll n,m,c; ll cha[A],thefirst[A],thesecond[A],ans[A]; int main () { scanf("%lld%lld",&n,&m); father [ 1 ] = 0 ; father [ 2 ] = 1 ; thefirst[1]=1;thefirst[2]=2; thesecond[1]=2;thesecond[2]=3;//最后统一 for(ll i=3;i<=100000;i++) cha[i]=(cha[i-1]+cha[i-2]+1)%mod; for(ll i=3;i<=100000;i++) thefirst[i]=(thefirst[i-1]+thefirst[i-2])%mod; for(ll i=3;i<=100000;i++) thesecond[i]=(thesecond[i-1]+thesecond[i-2]-1)%mod; ans[1]=thefirst[n]%mod;ans[2]=thesecond[n]%mod; c=cha[n]; // printf("1=%lld 2=%lld c=%lld\n",ans[1],ans[2],c); for(ll i=3;i<=100000;i++) ans [i] = (ans [i- 1 ] + ans [i- 2 ] c)% v; printf("%lld\n",ans[m]*2%mod); }