Find minimum positive integer x such that a ( x ^ 2 ) + b ( x ) + c >= k | C # implementation of the approach ; Function to return the minimum positive integer satisfying the given equation ; Binary search to find the value of x ; Return the answer ; Driver code
using System ; class GFG { static int MinimumX ( int a , int b , int c , int k ) { int x = int . MaxValue ; if ( k <= c ) return 0 ; int h = k - c ; int l = 0 ; while ( l <= h ) { int m = ( l + h ) / 2 ; if ( ( a * m * m ) + ( b * m ) > ( k - c ) ) { x = Math . Min ( x , m ) ; h = m - 1 ; } else if ( ( a * m * m ) + ( b * m ) < ( k - c ) ) l = m + 1 ; else return m ; } return x ; } public static void Main ( ) { int a = 3 , b = 2 , c = 4 , k = 15 ; Console . Write ( MinimumX ( a , b , c , k ) ) ; } }