U E D R , A S I H C RSS

crossedladder/곽병학

Describe crossedladder/곽병학 here
#include<iostream>
#include<vector>
#include <algorithm>
#include <math.h>
#include <cmath>

using namespace std;
double x,y,c;

double ft(double t) {
 	return c/(sqrt(pow(x,2) - pow(t,2))) + c/(sqrt(pow(y,2) - pow(t,2))) -1;
}

double bsearch(double low, double high) {
	double mid = (low + high)/2.0;
	double fm = ft(mid);
	double eps = 0.000001;

	if(abs(fm) < eps) 
		return mid;

	double fl = ft(low);

	if(fl * fm < 0)
		return bsearch(low, mid);
	else
		return bsearch(mid, high);
}

int main() {
	freopen("in.txt", "r", stdin);

	cin>>x>>y>>c;
	double min = x>y ? y : x;
	double ans = bsearch(0, min);

	cout.precision(3);
	cout<<std::fixed<<ans<<endl;

	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:38
Processing time 0.0076 sec