三分
code
#include<bits/stdc++.h>
#define ld double
#define ll long long
using namespace std;
ld a,b;
ll l=1,r=1e18;
ld k;
ld d(ll mid){
return b*(mid-1)+a/sqrt((ld)mid);
}
int main(){
cin>>a>>b;
while(l+2<r){
ll m1=l+(r-l)/3,m2=r-(r-l)/3;
if(d(m1)>d(m2)) l=m1;
else r=m2;
}
while(d(r-1)<d(r)) r--;
printf("%.10lf",d(r));
}
本文来自博客园,作者:liyixin,转载请注明原文链接:https://www.cnblogs.com/liyixin0514/p/18357764