Hard problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 497 Accepted Submission(s): 326
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.
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;
}