Created
July 3, 2021 05:10
-
-
Save shakayami/55be90e81f5abbf43f720fcc748dee08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod=10**9+7 | |
def sum_len(l,r): | |
if r-l==1: | |
return (len(str(l)))%mod | |
if l%10!=0: | |
return (len(str(l))+sum_len(l+1,r))%mod | |
if r%10!=0: | |
return (len(str(r-1))+sum_len(l,r-1))%mod | |
assert l%10==0 | |
assert r%10==0 | |
res=sum_len(l//10,r//10)*10+(r-l) | |
return res%mod | |
def solve(l,r): | |
if r-l==1: | |
return (len(str(l))*l)%mod | |
if l%10!=0: | |
return (len(str(l))*l+solve(l+1,r))%mod | |
if r%10!=0: | |
return (len(str(r-1))*(r-1)+solve(l,r-1))%mod | |
assert l%10==0 | |
assert r%10==0 | |
res=100*solve(l//10,r//10) | |
res+=45*sum_len(l//10,r//10) | |
res+=(r-l)*(l+r-1)//2 | |
res%=mod | |
return res | |
L,R=map(int,input().split()) | |
print(solve(L,R+1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment