Given a range [L, R] where 0 ≤ L ≤ R ≤ 108. The task is to find the count of integers from the given range that can be represented as (2x) * (3y).
Input: L = 1, R = 10
The numbers are 1, 2, 3, 4, 6, 8 and 9
Input: L = 100, R = 200
The numbers are 108, 128, 144, 162 and 192
Approach: Since the numbers, which are powers of two and three, quickly grow, you can use the following algorithm. For all the numbers of the form (2x) * (3y) in the range [1, 108] store them in a vector. Later sort the vector. Then the required answer can be calculated using an upper bound. Pre-calculating these integers will be helpful when there are a number of queries of the form [L, R].
Below is the implementation of the above approach:
- Ways to form an array having integers in given range such that total sum is divisible by 2
- Count integers in the range [A, B] that are not divisible by C and D
- Count integers in a range which are divisible by their euler totient value
- Queries to count integers in a range [L, R] such that their digit sum is prime and divisible by K
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Represent (2 / N) as the sum of three distinct positive integers of the form (1 / m)
- Most frequent factor in a range of integers
- Integers from the range that are composed of a single distinct digit
- Given an array and two integers l and r, find the kth largest element in the range [l, r]
- Count of integers of length N and value less than K such that they contain digits only from the given set
- Count of m digit integers that are divisible by an integer n
- Count ways to express even number ‘n’ as sum of even integers
- Count number of integers less than or equal to N which has exactly 9 divisors
- Count of all possible pairs of disjoint subsets of integers from 1 to N
- Count of integers that divide all the elements of the given array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.