[原创]HDU 5858 Hard problem 2016多校10 1002 [相交圆面积]【计算几何】

2016-08-19 16:04:23 Tabris_ 阅读数:504


博客爬取于2020-06-14 22:43:47
以下为正文

版权声明:本文为Tabris原创文章,未经博主允许不得私自转载。
https://blog.csdn.net/qq_33184171/article/details/52251839


题目连接 : 就当前HDU的情况 就先不给了

--------------------------------------------------------------------.
Hard problem

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 195 Accepted Submission(s): 148

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

----------------------------------------------.
题目大意 : 就是正方形边长为n时 求阴影面积 保留小数后两位

题目分析 :
当天不想做多校 然后队友给看了这题 说是小学奥数题目 所以就一直割补法 然后 GG
今天偶然看了看过去整理的模板 猛然看到一个叫做相交圆面积的东西 然后就想到了这道题目。。

然后大致是这样的。
这里写图片描述

小的圆是蓝的 打的圆是红的 绿色部分是相交的面积 (红色+蓝色==绿色?就当是对的了:不可能错)

然后根据相交圆面积求绿色部分 最后拿小圆的面积减去它 最后在乘个二就行了。。。

之后做题的时候只求一次边长为1的阴影部分面价就好了 因为平面图形 等比放大N倍 面积就是原来的n*n倍

就是这么水 然而被第一句话误导了 一直在寻找巧妙的办法…
什么小学奥数题目。。。 小学能学这个??!!!

附本题代码
-----------------------------------------------.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# include <bits/stdc++.h>
using namespace std;
# define lalal puts("*******");
const double PI = acos(-1);

struct Round {
double x, y;
double r;
}c1,c2;

double dis(Round a, Round b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

double solve(Round a, Round b)
{
double d = dis(a, b);
if (d >= a.r + b.r) return 0;

if (d <= fabs(a.r - b.r))
{
double r = a.r < b.r ? a.r : b.r;
return PI * r * r;
}

double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / 2. / a.r / d);
double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / 2. / b.r / d);
double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
return ret;
}

int main()
{
c1.x=0.0,c1.y=0.0,c1.r=1.0;
c2.x=0.5,c2.y=0.5,c2.r=0.5;

double s = solve(c1,c2);
s = PI*0.5-s*2;
// printf("%.15lf\n",s);

int _,n;
scanf("%d",&_);
while(_--)
{
scanf("%d",&n);
printf("%.2lf\n",s*n*n);
}
return 0;
}