hdu 5858 Hard problem【计算几何+思维】

Hard problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 108    Accepted Submission(s): 82

Problem Description

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 Output

0.29

Author

BUPT

Source

2016 Multi-University Training Contest 10 

 

题目大意:按照题目中给出的图所示(这里题干没有,对应到hdu就有图了),求出阴影部分面积。


思路:


1、首先连辅助线如图:


2、

然后根据已知条件,根据余弦定理可以求出角1和角2的大小,然后再求出三角形的底和高。

然后做以a为边的扇形面积,求出大三角形的面积,用扇形面积减去三角形面积得到大弓形面积。

然后做以a/2为边的扇形面积,求出小三角形的面积,用扇形面积减去三角形面积得到小弓形面积。

那么ans=2*(大弓形面积-小弓形面积)


Ac代码:



#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
const double PI=acos(-1.0);
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        double l;
        scanf("%lf",&l);
        double ans=acos((double)(5*sqrt(2)*1.0)/8.0);
        ans=ans*1.0/PI*180.0;
        ans*=2;
        double shan1=ans*1.0/360*1.0*PI*l*l;
        double sanjiaoxing=sqrt(7*1.0/32*1.0)*5*sqrt(2.0)/8.0*l*l;
        double xiaogongxing=shan1-sanjiaoxing;
        double ans2=acos((double)(-sqrt(2)*1.0/4.0));
        ans2=ans2/PI*180.0;
        ans2=180-ans2;
        ans2*=2;
        double shan2=ans2*1.0/360*1.0*PI*(l*1.0/2*1.0)*(l*1.0/2*1.0);
        double sanjiaoxing2=sqrt(7*1.0/32*1.0)*sqrt(1*1.0/32*1.0)*l*l;
        double dagongxing=(shan2-sanjiaoxing2);
        printf("%.2lf\n",2*(dagongxing-xiaogongxing));
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值