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

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
这道题是个数学题,一开始总想着切割算,结果是要加辅助线再利用三角函数。。。。差点就要用积分去算了。将靠近右边与靠近下边的交点分别与左上角顶点相连。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;
const double N=acos(-1.0);
int main()
{
double l;
int T;
cin>>T;
while(T--)
{
cin>>l;
double l1,l2,l3,l4;
l1=l*sqrt(2.0)/2;
l2=l;
l3=l/2;
double z,z1;
z=(l2*l2+l1*l1-l3*l3)/(2*l1*l2);
z1=(l1*l1+l3*l3-l2*l2)/(2*l1*l3);
double A,B,C;
A=acos(z);
B=acos(z1);
double s1,s2,s3;
s1=l2*l2*A/2;
s2=l1*l2*(sqrt(1-z*z))/2;
C=N-B;
s3=l3*l3*C/2;
double s;
s=4*(s3-(s1-s2));
printf("%.2f\n",s);
}
return 0;
}
本文介绍了一道针对小学奥林匹克数学竞赛的难题,任务是计算特定几何图形中阴影部分的面积。通过连接特殊点并利用三角函数计算,最终得出了解决方案。
578

被折叠的 条评论
为什么被折叠?



