题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3349
Problem Description
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:
Can you tell Gege the smallest area he must tidy to put his notebook?
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:

Can you tell Gege the smallest area he must tidy to put his notebook?
Input
T(T<=100) in the first line is the case number.
The next T lines each has 3 real numbers, L,A,B(0< L,A,B <= 1000).
L is the side length of the square desk.
A,B is length and width of the rectangle notebook.
The next T lines each has 3 real numbers, L,A,B(0< L,A,B <= 1000).
L is the side length of the square desk.
A,B is length and width of the rectangle notebook.
Output
For each case, output a real number with 4 decimal(printf("%.4lf",ans) is OK), indicating the smallest area Gege should tidy.
Sample Input
3
10.1 20 10
3.0 20 10
30.5 20.4 19.6
Sample Output
25.0000
9.0000
96.0400
题目大意:矩形书本a*b放在正方形桌子上L*L,求最小接触面积
题目思路:由正方形顶点对着书本肯定最小,刚好放到矩形宽的一半即可
代码:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOU(i,x,y) for(int i=x;i<=y;i++)
#define FOD(i,x,y) for(int i=x;i>=y;i--)
#define MEM(a,val) memset(a,val,sizeof(a))
#define PI acos(-1.0)
const double EXP = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll MINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
const int N = 1e6+5;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
std::ios::sync_with_stdio(false);
int t;
double L,a,b;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&L,&a,&b);
if(a>b)
swap(a,b);
double len = sqrt(2.0)*L/2; //对角线一半
double tmp = a/2;
double x=2*len-tmp;
if(tmp>len*2)
printf("%.4lf\n",L*L);
else if(tmp<len)
printf("%.4lf\n",tmp*tmp);
else
printf("%.4lf\n",L*L-x*x);
}
return 0;
}