Given four integers a, b, c and k. The task is to find the minimum positive value of x such that ax2 + bx + c ≥ k.
Input: a = 3, b = 4, c = 5, k = 6
For x = 0, a * 0 + b * 0 + c = 5 < 6
For x = 1, a * 1 + b * 1 + c = 3 + 4 + 5 = 12 > 6
Input: a = 2, b = 7, c = 6, k = 3
Approach: The idea is to use binary search. The lower limit for our search will be 0 since x has to be minimum positive integer.
Below is the implementation of the above approach:
- Find the minimum positive integer such that it is divisible by A and sum of its digits is equal to B
- Minimum product pair an array of positive Integers
- Find a positive number M such that gcd(N^M, N&M) is maximum
- Find Nth positive number whose digital root is X
- Find the smallest positive number missing from an unsorted array | Set 2
- Unbounded Binary Search Example (Find the point where a monotonically increasing function becomes positive first time)
- Given a string and an integer k, find the kth sub-string when all the sub-strings are sorted according to the given condition
- Find minimum x such that (x % k) * (x / k) == n
- Find the first, second and third minimum elements in an array
- Find minimum speed to finish all Jobs
- Find the maximum possible value of the minimum value of modified array
- Find minimum time to finish all jobs with given constraints
- Find the minimum element in a sorted and rotated array
- Find the K-th minimum element from an array concatenated M times
- Program to find the minimum (or maximum) element of an 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 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.