#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define nl "\n"
ld temperature(ld h,ld c,ll cups)
{
return (double)((h*cups)+c*(cups-1))/(2*cups-1);
}
ll bin_search(ld h,ld c,ld t)
{
ld dif=1e12;
ll f;
ll low=3,high=1e12;
while(low<=high)
{
ll mid=(low+high)/2;
f=mid;
ld s=temperature(h,c,mid);
if(abs(t-s)>abs(t-dif)) return f;
f=mid;
if(temperature(h,c,mid)>t)
{
low=mid+1;
}else
{
high=mid-1;
}
}
}
int main()
{
IOS;
int T;
cin>>T;
while(T--)
{
ld h,c,t;
cin>>h>>c>>t;
if(t>=h) cout<<"1\n";
else if(t<=(h+c)/2) cout<<"2\n";
else cout<<2*(bin_search(h,c,t))-1<<nl;
}
return 0;
}
It seems that your code finished the while loop without ever executing the
return f;
statement. In that case the code expects you to return a value at the end of the function but there is no return statement.Binsearch should return ll, but in your code it returns nothing