- 浏览: 35996 次
文章分类
- 全部博客 (41)
- 卧鸟个去 (2)
- Transform (2)
- Mathmatic (9)
- Plant-Tree (7)
- Data-Struct (12)
- Red-Black-Tree (1)
- Radix-Tree (1)
- Trie (2)
- String (4)
- BST (2)
- Amazing-Union-Find-Set (1)
- HDU (27)
- OJ (32)
- BFS (3)
- Pretty-Suffix-Array (2)
- POJ (6)
- Graceful-Segment-Tree (2)
- Geometry (6)
- Priority-Queue (2)
- Dynamic-Programing (1)
- DP (3)
- LCS (1)
- Convex-Hull (2)
- Triangulation (1)
- DFS (3)
- Combinatorial-Mathematics (2)
- Big-Number (1)
- Statistic (3)
- STL (1)
- Shortest-Path (3)
- ZOJ (1)
- Leftist-Tree (1)
- Prime (1)
- Binary-Index-Tree (1)
- (1)
- Stack (1)
- SPFA (0)
- CRT (1)
Tell me the area
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 900 Accepted Submission(s): 284
Problem Description
There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area.
Input
There are many cases. In each case, there are two lines. Each line has three numbers: the coordinates (X and Y) of the centre of a circle, and the radius of the circle.
Output
For each case, you just print the common area which is rounded to three digits after the decimal point. For more details, just look at the sample.
Sample Input
0 0 2 2 2 1
Sample Output
0.108
Author
wangye
Source
Recommend
wangye
几何题,分三种情况讨论…………
假设圆A半径r1 < 圆B半径r2
d0 = 圆心距
d1 = A圆心到交线距离
d2 = B圆心到交线距离
arc1 = A圆优弧弓型面积
arc2 = B圆优弧弓型面积
情况一:
d0 >= r1 + r2
两圆相离或外切,area = 0.0
情况二:
d0 + r1 <= r2
两圆内含或内切,area = A圆面积
情况三:
r2 - r1 < d0 < r1 + r2
相交有两小类:
1、d0 >= d1, area = arc1 + arc2
2、d0 < d1, area = arc1 + A圆面积 - arc2
下面贴上代码:
4290504 | 2011-07-29 21:40:46 | Accepted | 1798 | 62MS | 208K | 1115 B | C++ | 10SGetEternal{(。)(。)}! |
#include <iostream> #include <cmath> using namespace std; #define fp(x) ((x) * (x)) #define fmin(x, y) ((x) < (y)? (x): (y)) int main() { double x1, y1, r1, x2, y2, r2; double A, B, C, d, d0, d1, d2, ang1, ang2, taa1, taa2, ara1, ara2, area; while (scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &r1, &x2, &y2, &r2) != EOF) { if (r1 > r2) //保证圆A半径小于圆B { swap(r1, r2); swap(x1, x2); swap(y1, y2); } A = 2 * (x2 - x1); B = 2 * (y2 - y1); C = fp(x1) - fp(x2) + fp(y1) - fp(y2) + fp(r2) - fp(r1); d = sqrt(fp(A) + fp(B)); d0 = sqrt(fp(x1 - x2) + fp(y1 - y2)); d1 = abs(A * x1 + B * y1 + C) / d; d2 = abs(A * x2 + B * y2 + C) / d; if (d0 >= r1 + r2) area = 0.0; else if (d0 + r1 <= r2) area = acos(-1.0) * fp(r1); else { ang1 = acos(d1 / r1); ang2 = acos(d2 / r2); taa1 = r1 * d1 * sin(ang1); taa2 = r2 * d2 * sin(ang2); ara1 = ang1 * fp(r1); ara2 = ang2 * fp(r2); area = ara2 - taa2; if (d0 >= d2) area += ara1 - taa1; else area += acos(-1.0) * fp(r1) - ara1 + taa1;; } printf("%.3lf\n", area); } return 0; }
注意DB错误……a - (c + d) = a - c + d
发表评论
-
HDU 1370 Biorhythms
2011-08-03 10:27 1150Biorhythms Time Limit: 2000/10 ... -
HDU 1075 What Are You Talking About
2011-08-04 11:00 833What Are You Talking About Tim ... -
HDU 1058 Humble Numbers
2011-08-02 15:55 1170Humble Numbers Time Limit: 200 ... -
HDU 2095 find your present (2)
2011-08-02 16:13 765find your present (2) Time Lim ... -
HDU 1022 Train Problem I
2011-08-02 21:00 995Train Problem I Time Limit: 20 ... -
2142 HDU box
2011-08-02 21:21 734box Time Limit: 3000/1000 MS ( ... -
HDU 2151 Worm
2011-08-01 20:48 787Worm Time Limit: 1000/1000 MS ... -
HDU 2722 Here We Go(relians) Again
2011-08-02 00:06 968Here We Go(relians) Again Time ... -
HDU 3791 二叉搜索树
2011-08-02 14:26 1160二叉搜索树 Time Limit: 20 ... -
PKU 2352 Stars
2011-07-31 21:47 985Stars Time Limit: 1000MS ... -
PKU 2774 Long Long Message
2011-07-31 21:26 864Long Long Message Time Li ... -
PKU 2777 Count Color
2011-07-31 21:31 767Count Color Time Limit: 1 ... -
HDU 2098 分拆素数和
2011-07-31 21:08 1014分拆素数和 Time Limit: 1000/1000 MS ... -
ZOJ 3512 Financial Fraud .
2011-07-31 20:49 1230Financial Fraud Time Limit: 3 ... -
HDU 2962 Trucking .
2011-07-31 20:46 639Trucking Time Limit: 20000/100 ... -
HDU 1596 find the safest road .
2011-07-31 20:45 571find the safest road Time Limi ... -
HDU 2553 N皇后问题 .
2011-07-31 20:20 661N皇后问题 Time Limit: 2000/1000 MS ... -
HDU 1392 Surround the Trees .
2011-07-31 20:19 758Surround the Trees Time Limit: ... -
HDU 1234 开门人和关门人 .
2011-07-31 20:17 642开门人和关门人 Time Limit: 2000/1000 ... -
HDU 1174 爆头 .
2011-07-31 20:16 582爆头 Time Limit: 2000/1000 M ...
相关推荐
hdu5102的ac源码。算法:队列、数据结构、图论、模拟。题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和。
解题报告|ACM|程序设计参考程序以及题目的分析
杭电OJ部分答案,可以很简单的解决a+b求和问题及其他问题。
HDU的一题........HDU DP动态规
杭电OnlineJudge 200-2099的解题报告
杭电选课插件
2.18.1 HDU4656 卷积取模 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 2.19 其它公式 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.19.1 Polya . . . ....
HDUACM2010版03递推求解.ppt
HDU 里面的2000~2099道题目的源码。谢谢支持
ACM HDU 1404 Digital Deletions(博弈).docx
杭电 hdu acm 第1084题的解法,ac过了,是一位学长教我的.内有一些中文说明.
ACM HDU题目分类,我自己总结的大概只有十来个吧
Hdu 1020解题报告,http://acm.hdu.edu.cn/showproblem.php?pid=1020
杭电acm 一些java语言实现的水题目
本资源为HDU数字图像处理课程 浙江省在线平台的视频课后作业 仅供参考 假设我们有一个mat型的单通道图像,命名为srcMat,我们想得到第i行,第j列的像素值则可以用一下的代码 A. int value= srcMat.at(i)(j)[0]; B...
杭电ACM2000-2099题的解题报告