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