Given three integer K, L and R (range [L, R]), the task is to find the minimum number of elements the range must be extended by so that the count of elements in the range is divisible by K.
Input: K = 3, L = 10, R = 10
Count of elements in L to R is 1.
So to make it divisible by 3 , increment it by 2.
Input: K = 5, L = 9, R = 12
- Count the total number of elements in the range and store it in a variable named count = R – L + 1.
- Now, minimum number of elements that need to be added to the range will be K – (count % K).
Below is the implementation of the above approach:
- Count numbers in a range that are divisible by all array elements
- Minimum steps to make all the elements of the array divisible by 4
- Count elements in the given range which have maximum number of divisors
- Find set of m-elements with difference of any two elements is divisible by k
- Minimum number of elements to be removed so that pairwise consecutive elements are same
- Minimum sum of the elements of an array after subtracting smaller elements from larger
- Maximum difference elements that can added to a set
- Count of elements whose absolute difference with the sum of all the other elements is greater than k
- Count the numbers divisible by 'M' in a given range
- Count numbers in range 1 to N which are divisible by X but not by Y
- Minimum positive integer divisible by C and is not in range [A, B]
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3
- Count numbers in range L-R that are divisible by all of its non-zero digits
- Count of Numbers in a Range divisible by m and having digit d in even positions
- Count integers in a range which are divisible by their euler totient value
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.