#include <bits/stdc++.h>
using namespace std;
long long n, m, g, a, b, l, r, p, q;
double ans=1e18;
double cal(long long g){
    return a / sqrt(g) + b * (g-1);
}
int main(){
    scanf("%lld%lld", &a, &b);
    l = 1, r = (a+b-1) / b;
    while(r-l > 5){//范围大三分答案
        m = (r-l)/3, p = l+m, q = r-m;
        if(cal(p) > cal(q)) l = p;
        else r = q;
    }
    for(g=l; g<=r; g++){//范围小暴力枚举
        ans = min(ans, cal(g));
    }
    printf("%.10lf\n", ans);
    return 0;
}

作者 crxis

发表回复