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 smallest positive number Y such that Bitwise AND of X and Y is Zero
- 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 node whose xor with x gives minimum value
- Find the first, second and third minimum elements in an array
- Find the node whose sum with X has minimum set bits
- Find the node whose absolute difference with X gives minimum value
- Find the maximum possible value of the minimum value of modified array
- Find the root of the sub-tree whose weighted sum XOR with X is minimum
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.