mod3 dp Biu——
好题
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll f[200050][6];
ll mod=1e9+7;
int main()
{
int n,l,r;
cin>>n>>l>>r;
ll mod0=r/3-(l-1)/3;
ll mod1=(r+2)/3-(l+2-1)/3;
ll mod2=(r+1)/3-(l)/3;
f[1][0]=mod0;
f[1][1]=mod1;
f[1][2]=mod2;
for(int i=2;i<=n;i++)
{
f[i][0]=f[i-1][0]*mod0+f[i-1][1]*mod2+f[i-1][2]*mod1;
f[i][1]=f[i-1][0]*mod1+f[i-1][1]*mod0+f[i-1][2]*mod2;
f[i][2]=f[i-1][0]*mod2+f[i-1][1]*mod1+f[i-1][2]*mod0;
f[i][0]%=mod;
f[i][1]%=mod;
f[i][2]%=mod;
}
cout<<f[n][0]<<endl;
return 0;
}