One integer number x is called "Mountain Number" if:
(1) x>0 and x is an integer;
(2) Assume x=a[0]a[1]...a[len-2]a[len-1](0≤a[i]≤9, a[0] is positive). Any a[2i+1] is larger or equal to a[2i] and a[2i+2](if exists).
For example, 111, 132, 893, 7 are "Mountain Number" while 123, 10, 76889 are not "Mountain Number".
Now you are given L and R, how many "Mountain Number" can be found between L and R (inclusive) ?
Input
The first line of the input contains an integer T (T≤100), indicating the number of test cases.
Then T cases, for any case, only two integers L and R (1≤L≤R≤1,000,000,000).
Output
For each test case, output the number of "Mountain Number" between L and R in a single line.
Sample Input
Sample Output
题意:
如果一个>0的整数x,满足a[2*i+1] >= a[2*i]和a[2*i+2],则这个数为Mountain Number。
给出L, R,求区间[L, R]有多少个Mountain Number。
思路:
数位DP,判断当前是偶数位还是奇数位(从0开始),
如果是偶数位,那么它要比前一个数的值小,
如果是奇数位,那么它要比前一个数的值大。
不明白为什么开long long 就答案错误