【HDU3349】lazy gege(计算几何)

Categories: 数据结构和算法
Tags: ,
Comments: No Comments
Published on: 2011 年 05 月 12 日

Gege hasn't tidied his desk for long,now his desk is full of things.
This morning Gege bought a notebook,while to find somewhise to put it troubles him.
He wants to tidy a small area of the desk, leaving an empty area, and put the notebook there, the notebook shouldn't fall off the desk when putting there.
The desk is a square and the notebook is a rectangle, area of the desk may be smaller than the notebook.
here're two possible conditions:

题解:矩形重心在桌子上即可使其不掉落。。。所以根据长宽分情况计算一下取个小值就行了。这种题一般就是这样,就那么几种特殊方法,都计算一下看看哪个最小输出就行了,但是一直WA,最后发现这题十分的坑爹,给的矩形的长宽数据竟然有 长边比宽边还短的情况。。。。十分的坑爹。这让我想起了蚂蚁爬橡皮筋那题。。。也是十分的坑爹啊。。。有木有!!!说的是给三个整型数,结果给的却是实数,double型,艹了。。。有木有!!!

#include <iostream>
#include <cmath>
using namespace std;
int main()
	int n;
	cin >> n;
	while (n--)
		double L,A,B;
		cin >> L >> A >> B;
		if (A>B)
		double ans,t = L*sqrt(2.0)/2;
		if (A/2.0 <= t)
			ans = A*A/4.0;
		else if (A/2 <= 2*t)
			double T = 2*t-A/2;
			ans = L*L-T*T;
			ans = L*L;


No Comments - Leave a comment

Leave a comment

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Welcome , today is 星期六, 2019 年 02 月 23 日