problem id:--http://practice.geeksforgeeks.org/problems/min-value-of-x/0
In this problem you need to find the Positive integer root of the given equation
Since given equation is this ax^2+bx+c>=k
First convert it into normal form
ax^+bx+(c-k)>=0
Now find the +ve root of the quadratic solution . and if it's a decimal number Then just take ceil
of that value. That's all . Happy coding :)
code:--
#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
int main()
{
int t;
sc(t);
while(t--)
{
double a,b,c,k;
cin>>a>>b>>c>>k;
double x1;
x1=(-b+sqrt(b*b-4*a*(c-k)))/(2*a);
cout<<ceil(x1)<<'\n';
}
return 0;
}
In this problem you need to find the Positive integer root of the given equation
Since given equation is this ax^2+bx+c>=k
First convert it into normal form
ax^+bx+(c-k)>=0
Now find the +ve root of the quadratic solution . and if it's a decimal number Then just take ceil
of that value. That's all . Happy coding :)
code:--
#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
int main()
{
int t;
sc(t);
while(t--)
{
double a,b,c,k;
cin>>a>>b>>c>>k;
double x1;
x1=(-b+sqrt(b*b-4*a*(c-k)))/(2*a);
cout<<ceil(x1)<<'\n';
}
return 0;
}