设宽为a,那么可以求得
c/sqrt( y^2 - a ^2 ) + c/sqrt( x^2 - a ^2 ) = 1
又 a的范围是 大于0 小于 min(x,y)
二分搜索即可
AC代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
double x, y, c;
bool judge( double a ){
// double temp1 = c * ( sqrt( y * y - a * a ) + sqrt( x * x - a * a ) );
// double temp2 = sqrt( y * y - a * a ) * sqrt( x * x - a * a );
if( c * ( sqrt( y * y - a * a ) + sqrt( x * x - a * a ) ) >= sqrt( y * y - a * a ) * sqrt( x * x - a * a ) ){
return true;
}else{
return false;
}
}
int main(){
int T, Case = 1;
cin >> T;
while( T-- ){
cin >> x >> y >> c;
double l = 0, r = min( x, y ), mid;
while( r - l > 1e-6 ){
mid = ( l + r ) / 2;
if( judge( mid ) ){
r = mid;
}else{
l = mid;
}
}
printf( "Case %d: %.7lf\n", Case++, l );
}
return 0;
}