解题报告CF1105C Ayoub and Lost Array
开学才写出来
此题
枚举
转移方程为
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long n,l,r,f[200020][3],k[3];
int main(){
cin>>n>>l>>r;
for(int i=0;i<=2;i++){
k[i]=(r-i+3)/3-(l-i+2)/3;
}
f[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=2;j++){
for(int h=0;h<=2;h++){
f[i][(j+h)%3]=(f[i][(j+h)%3]+f[i-1][j]*k[h])%mod;
}
}
}
cout<<f[n][0]<<endl;
}