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
 
 
11
 

Sample Output
 
 
0.29


给出正方形边长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即可。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<string>
#define LL long long
using namespace std;
double pi=acos(-1);
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; // 两个三角形的面积
       double a = sqrt(7)*5/16;
       double s2 = asin(a)/(2*pi) * pi * r * r; // 大扇形面积
       double b = sqrt(7)/4;
       double s3 = (pi-asin(b))/(2*pi) * pi * (r/2) * (r/2); //小扇形面积
       printf("%.2lf\n", 2*(s3+s1-s2) );
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值