All submissions for this problem are available.
A digit in a number N is a minima if it is lesser than both the digits adjacent to it. Similarly, a digit is a maxima if it is greater than both the digits adjacent to it. The slope of N is the number of digits in N (leaving out the first and the last digit) which are either a minima or a maxima. Given A and B, count the sum of the slopes of all numbers between A and B.
The first line contains the number of test cases T. Each of the next T lines contains two integers A and B.
Output T lines one for each test case, containing the required sum for the corresponding test case.
Sample Input : 3 101 101 1 100 100 150
Sample Output : 1 0 19
Constraints : 1 <= T <= 50000 1 <= A <= B <= 1000000000000000 (10^15)
|Tags||may10, medium, syco|
|Time Limit:||0.102564 sec|
|Source Limit:||10000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.