HDU - 5858 Hard problem(数学)

点击打开题目链接

Hard problem

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

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

Recommend

wange2014

Statistic | Submit | Discuss | Note

今天最后一次省赛组队集训赛,村庄猪去约会去了,所以只剩下我和yxm两个人了。K是一个打表题出题速度比较快,然后三个小时怒怼这个数学题。

题意很明了,求阴影部分面积,纯数学知识,我感觉这个题思路很多,比赛后他们有说用两个圆相交的模板可以做。这里只取我的思路说一下。

思路:给出正方形边长L。BD为圆的半径为L/2,BA为正方形对角线的1/2,AD为1/4圆AEF的半径为L,则能根据余弦定理求出∠a,进而求出∠b,进而求出扇形ACD的面积以及三角形ABD的面积。用扇形ACD的面积减去两倍的三角形ABD的面积为饼BCD的面积。然后根据三角形ABD的三边求得∠c,进而求得∠d,进而求得以B为圆心的扇形BCD的面积,然后用扇形BCD的面积减去饼BCD的面积即为阴影部分的面积,然后乘以2即可。

我们队在这个题上卡了三小时不是思路问题,而是代码实现上出了问题,cmath中的sin和asin全为弧度制,在求∠d时,asin值对应有两个,所以要用pi减。(TAT 实在不应该卡在这)

附上AC代码:

#include<bits/stdc++.h>

const double pi=acos(-1);
using namespace std;
const int maxn=1000;
int a[maxn],b[maxn];

int main()
{
    int cases;
    double r;
    scanf("%d",&cases);
    while(cases--)
    {
       cin >> r;
       double s1 = 2* sqrt(7)/16 * r *r; // 两个三角形的面积 0.3319
       //cout << s1;
       double a = sqrt(7)*5/16;
       double s2 = asin(a)/(2*pi) * pi * r * r; // 大扇形面积 0.4866
       //cout << s2;
       //cout << s2 - s1;
       double b = sqrt(7)/4;
       //cout <<  asin(b)*(180/pi);
       double s3 = (pi-asin(b))/(2*pi) * pi * (r/2) * (r/2); //小扇形面积
       //cout << s3;
       printf("%.2lf\n", 2*(s3+s1-s2) );
    }
    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Chook_lxk

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值