UOJ Logo 黑暗爆炸OJ

DARKBZOJ

#3539. [Usaco2014 Open]Odometer

Statistics 下载数据

Description

 Farmer John's cows are on a road trip! The odometer on their car displays an integer mileage value, starting at X (100 <= X <= 10^18) miles at the beginning of their trip and ending at Y (X <= Y <= 10^18) miles at the end of their trip. Whenever the odometer displays an 'interesting' number (including at the start and end of the trip) the cows will moo. A number is 'interesting' if when you look at all its digits except for leading zeros, at least half of these should be the same. For example, the numbers 3223 and 110 are interesting, while the numbers 97791 and 123 are not. Help FJ count how many times the cows will moo during the trip.

定义”有趣的数:把该数的前缀零去掉后,存在一个数字使得其出现次数至少为数位总数的一半,例如3223,110.
求[X,Y]中有多少个有趣的数”.

Input

* Line 1: The first line will contain two integers, X and Y, separated by a space.

Output

 * Line 1: A single integer containing how many times the cows will moo during the trip.

Sample Input

110 133

INPUT DETAILS: The trip starts with the odometer at 110 and ends at 133.

Sample Output

14
OUTPUT DETAILS: The cows moo when the odometer reads 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 121, 122, 131, and 133.

Hint

Source

Silver By liyizhen2