2014
03-16

lazy gege

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?

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.

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.

3
10.1 20 10
3.0 20 10
30.5 20.4 19.6

25.0000
9.0000
96.0400

/*

2013-04-22

*/

#include"stdio.h"
#include"math.h"
int main()
{
int t;
double l,a,b,tem;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&l,&a,&b);
if(a>b)
{
tem=a;
a=b;
b=tem;
}
if(sqrt(l*l+l*l)<a/2)
printf("%.4f\n",l*l);
else if(a/2<sqrt(l*l+l*l)/2)
{
printf("%.4f\n",a*a/4);
}
else
{
printf("%.4f\n",l*l-(sqrt(l*l*2)-a/2)*(sqrt(l*l*2)-a/2));
}
}
return 0;
}

1. 我还有个问题想请教一下，就是感觉对于新手来说，递归理解起来有些困难，不知有没有什么好的方法或者什么好的建议？