Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- ll function_value(ll a,ll b,ll c,ll x)
- {
- return (a*x*x+b*x+c);
- }
- ll find_x(ll a,ll b,ll c,ll k)
- {
- ll l=0,r=1000000,ans;
- while(l<=r)
- {
- ll mid=(l+r)/2;
- if(function_value(a,b,c,mid)<k)
- {
- l=mid+1;
- }
- else
- {
- ans=mid;
- r=mid-1;
- }
- }
- return ans;
- }
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- ll a,b,c,k;
- cin>>a>>b>>c>>k;
- cout<<find_x(a,b,c,k)<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement