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 smallest positive number Y such that Bitwise AND of X and Y is Zero
- 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)
- Find a pair (n,r) in an integer array such that value of nCr is maximum
- Find a pair (n,r) in an integer array such that value of nPr is maximum
- Queries to find the left-most given type integer in a binary array
- 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
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.