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.
![](https://i-blog.csdnimg.cn/blog_migrate/d8740ee759f31eb99b24e8d7a5c42d78.jpeg)
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;
}