HDU - 5858 Hard problem (非常详细的解答)

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.




Input

The first line contains a integer T(1<=T<=10000), means the number of the test case. Each case contains one line with integer l(1<=l<=10000).

Output

For each test case, print one line, the shade area in the picture. The answer is round to two digit.

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;
}

有不懂的,可以问我!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值