样例没过 A了(或者数据不水,是其他问题)
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
string l,r;
int dp[1005][2][2][2][10][10];
signed main(){
cin>>l>>r;
int n=r.size();
int len=l.size();
l=string(n-len,'0')+l;
dp[0][0][0][0][0][0]=1;
for(int i=0;i<n;i++){
for(int x=0;x<=1;x++){
for(int y=0;y<=1;y++){
for(int th=0;th<=1;th++){
for(int j1=0;j1<=9;j1++){
for(int j2=0;j2<=9;j2++){
int L=(x?0:l[i]-'0');
int R=(y?9:r[i]-'0');
for(int j3=L;j3<=R;j3++){
int tx=x|(j3>l[i]-'0');
int ty=y|(j3<r[i]-'0');
int tth=th|(i>0&&j2==j3)|(i>1&&j1==j3);
dp[i+1][tx][ty][tth][j3][j2]=(dp[i+1][tx][ty][tth][j3][j2]+dp[i][x][y][th][j2][j1])%mod;
}
}
}
}
}
}
}
int ans=0;
for(int x=0;x<=1;x++){
for(int y=0;y<=1;y++){
for(int th=0;th<=1;th++){
for(int i=0;i<=9;i++){
for(int j=0;j<=9;j++){
if(!th){
continue;
}
ans=(ans+dp[n][x][y][th][j][i])%mod;
}
}
}
}
}
cout<<ans;
return 0;
}