Skip to content

Instantly share code, notes, and snippets.

@tokugh
Last active July 6, 2021 13:58
Show Gist options
  • Save tokugh/1dc514eb878bdd8bc4cd32ab9441edc2 to your computer and use it in GitHub Desktop.
Save tokugh/1dc514eb878bdd8bc4cd32ab9441edc2 to your computer and use it in GitHub Desktop.
const MOD: i128 = 1_000_000_007;
fn main() {
proconio::input!{ l: i128, r: i128, };
let mut ans = 0;
for i in 0..=18 {
let min = 10i128.pow(i).max(l);
let max = (10i128.pow(i + 1) - 1).min(r);
if min <= max {
ans += (i as i128 + 1) * (min + max) * (max - min + 1) / 2;
ans %= MOD;
}
}
println!("{}", ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment