UVa 10545 Maximal Quadrilateral (有内切圆的四边形面积)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1486


公式参考维基百科但还是觉得哪里不对(待研究,坑)


完整代码:

/*0.018s*/

#include<cstdio>
#include<cmath>

int main()
{
	int t, cas = 0, p, a, b;
	double c, d;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d%d", &p, &a, &b);
		printf("Case %d: ", ++cas);
		if (2 * a > p || 2 * b >= p || a == 0 || b == 0)
		{
			puts("Eta Shombhob Na.");
			continue;
		}
		double c = (double)p / 2 - a;
		double d = (double)p / 2 - b;
		printf("%.6f\n", sqrt(a * b * c * d) * 2 / (a + b + c + d));
	}
}


你可能感兴趣的:(C++,ACM,uva)