整数值域上的三分
#include<bits/stdc++.h>
#define pt printf(">>>")
#define mid (((l)+(r))/2)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+10,inf=1e18+10,mod=998244353;
ld a,b;
ld f(ld x){return a/sqrt(1+x)+x*b;}
int main(){
cin >> a >> b;
ll l=0,r=a/b;
while(l+2<r){
if(f(mid)<f(mid+1))r=mid+1;
else l=mid;
}
ld ans=inf;
for(ll i=l;i<=r;i++)ans=min(ans,f(i));
cout << fixed << setprecision(7) << ans;
return 0;
}
实数值域上的三分
标签:ld,ll,typedef,long,三分,define From: https://www.cnblogs.com/alric/p/18209437