Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll l, r;
- cin >> l >> r;
- ll f = l <= 9;
- ll num = 9;
- ll ans = 0;
- ll cnt = 1;
- while (r >= num)
- {
- r -= num;
- ans += num;
- num = num * 10 + 9;
- cnt++;
- }
- if (r) ans += r / cnt;
- num = 9;
- cnt = 1;
- ll ans1 = 0;
- while (l >= num)
- {
- l -= num;
- ans1 += num;
- num = num * 10 + 9;
- cnt++;
- }
- if (l) {
- ans1 += l / cnt;
- if (l % cnt && l > 1) ans1++;
- }
- cout << ans - ans1 + f;
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement