Test instructions
There is a number equal to the highest digit in single-digit numbers, and the number of such numbers within the range of L,r.
Ideas:
Find the law to know when the n>10 when the answer to remove the digit is equal to N/10, and then consider whether the first number is less than the last one, less than minus one, but also to add the number of bits must exist 9 digits
Import Java.util.Scanner; Public classXXZ { Public Static void Main(string[] args) {Scanner SC =NewScanner (System.inch);LongL = Sc.nextlong ();LongR = Sc.nextlong ();LongAns = Solve (R)-Solve (L-1); System. out. println (ANS); } Public Static Long Solve(Longx) {String _x = string.valueof (x);returnx/Ten-1+ Math.min (9, x) + (_x.charat (0) <= _x.charat (_x.length ()-1) ?1:0); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Codeforces 204 (Div.1 A) Little Elephant and Interval (greedy)