题意:中文题。
分析:直接枚举第i位和第j位对应的贡献,确定了第i位和第j位会有影响那么长度也确定了i+j-1,然后在可行范围内计数即可。
代码:
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=100010;
const int mod=100000000;
const int MOD1=1000000007;
const int MOD2=1000000009;
const double EPS=0.00000001;
typedef long long ll;
const ll MOD=1000000007;
const int INF=1000000010;
const ll MAX=1ll<<55;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned long long ull;
int d[25];
ll cal[25];
ll suan(ll x,int a,int b,int rev) {
ll ret=0;
int i,j,len=a+b-1;
if (!rev) {
if (a==1) return cal[a+b-2]*2025%MOD;
else return cal[a+b-3]*9*2025%MOD;
} else {
for (i=len;i>b;i--) ret=(ret+(d[i]-(i==len))*2025*cal[i-2]%MOD)%MOD;
for (i=1;i<d[b];i++) ret=(ret+cal[b-1]*i*45%MOD)%MOD;
for (i=b-1;i>a;i--) ret=(ret+d[i]*cal[i-1]*d[b]*45%MOD)%MOD;
for (i=1;i<d[a];i++) ret=(ret+cal[a]*d[b]*i%MOD)%MOD;
ret=(ret+(x%cal[a]+1)*d[a]*d[b]%MOD)%MOD;
}
return ret;
}
ll get(ll x) {
int i,j,len=0;
ll a=x,ret=0;
if (x<1) return 0;
while (a) { len++;d[len]=a%10;a/=10; }
for (i=1;i<=len;i++)
if (2*i-1>len) break ;
else {
if (2*i-1<len) {
if (i==1) ret=(ret+285)%MOD;
else ret=(ret+cal[2*i-2]*9*285%MOD)%MOD;
}
if (2*i-1==len) {
for (j=len;j>i;j--)
ret=(ret+(d[j]-(j==len))*285*cal[j-1]%MOD)%MOD;
for (j=1;j<d[i];j++) ret=(ret+cal[i]*j*j%MOD)%MOD;
ret=(ret+d[i]*d[i]*(x%cal[i]+1)%MOD)%MOD;
}
}
for (i=1;i<=len;i++)
for (j=i+1;j<=len;j++)
if (i+j-1>len) break ;
else ret=(ret+2*suan(x,i,j,i+j-1==len))%MOD;
return ret;
}
int main()
{
ll l,r;
cal[1]=1;
for (int i=2;i<=20;i++) cal[i]=cal[i-1]*10%MOD;
scanf("%I64d%I64d", &l, &r);
printf("%I64d\n", (get(r)-get(l-1)+MOD)%MOD);
return 0;
}