Hard problem
cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school students. It is too difficult for cjj. Can you solve it?
Give you the side length of the square L, you need to calculate the shaded area in the picture.
The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
Give you the side length of the square L, you need to calculate the shaded area in the picture.
The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
Input
Output
Sample Input
1
1
Sample Outpu
0.29
题意:
求 两块 黑色的阴影面积。
思路:
利用数学公式,一步一步化简。
已知三角形的三边长度,求面积 。用海伦公式 ==>SA
用余弦定理 ==> 角a 的度数 da
利用扇形的面积公式 ==>SA_B , 进而 ==> SB
用余弦定理和 换角公式 cos(pai - a) = -cosa ==> B的度数 dB
利用扇形的面积公式 ==>SB_C ,进而 ==>SC(是 1/4 的阴影面积)
AC代码:
#include <cstdio>
#include <cmath>
int main()
{
int T;
scanf("%d",&T);
double L;
double a,b,c,p;
double SA,SA_B,SB,SB_C,SC;
double db,cos_a ,dB;
double ans;
while(T--){
scanf("%lf",&L); // (1 <= L <= 10000)
a = L;
b = L/2;
c = sqrt(2.0)*L/2;
p = (a+b+c)/2; //半周长
SA = sqrt(p*(p-a)*(p-b)*(p-c) );
//db = acos( (a*a+c*c-b*b)/(2*a*c) );//化简之后是下面
db = ( acos( 1.25/sqrt(2.0) ) );
SA_B = db *a*a/2;
SB = SA_B - SA;
//cos_a = b*b+c*c-a*a)/(2*b*c);
//dB = acos( -cos_a); //化简之后是下面
dB = acos( sqrt(2.0)/4 );
SB_C = dB *b*b/2;
SC = SB_C - SB;
ans = 4*SC; //最终结果
printf("%.2f\n",ans);
}
return 0;
}
有不懂的,可以问我!