LightOJ 1062 Crossed Ladders(二分)

int main(int argc, const char * argv[])
{    
    int kase;cin >> kase;
    while(kase--) {
        double x, y, c;cin >> x >> y >> c;
        double l = 0, r = min(x, y);
        Rep(i, 1, 100) {
            double mid = (l + r) / 2.0;
            double angle1 = acos(mid / x);
            double angle2 = acos(mid / y);
            double t = c / tan(angle1) + c / tan(angle2);
            if (t < mid) l = mid;
            else r = mid;
        }
        printf("Case %d: %.12lf\n", ++nCase, l);
    }
    return 0;
}

你可能感兴趣的:(二分)