← 返回 ibm 的题目列表Count numbers of the form 3^x * 5^y within a range
类型:online_judge
Given a closed interval [L, R] (0 < L <= R), count how many integers in the interval can be written as:
n = 3^x * 5^y, where x and y are non-negative integers (x, y >= 0).
Return the number of distinct integers that fall within [L, R].
Input
One line with two integers L R.
Output
Print one integer: the count of numbers in [L, R] of the form 3^x * 5^y.
Constraints / Notes
Handle overflow when generating powers; stop expanding once values exceed R.
Use 64-bit integers (e.g., long).
Example
Input: 1 100 Output: 7
Explanation: 1, 3, 5, 9, 15, 25, 45.
Example
Input
1 1
Output
1