poj 2546 Circular Area 两圆面积交

题意:

给两个圆,求它们的面积交。

分析:

海伦公式,余弦定理等可解。

代码:

//poj 2546
//sep9
#include <iostream>
#include <cmath>
using namespace std;
const double pi=acos(-1.0);

int main()
{
	double x1,y1,r1,x2,y2,r2;
	scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);
	double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	if(d>=r1+r2){
		printf("%.3lf",0);
		return 0;
	}
	if(d<=max(r1,r2)-min(r1,r2)){
		printf("%.3lf",pi*min(r1,r2)*min(r1,r2));
		return 0;
	}
	double p=(r1+r2+d)/2;
	double s=2*sqrt(p*(p-r1)*(p-r2)*(p-d));
	double A1=2*acos((r1*r1+d*d-r2*r2)/(2*r1*d));
	double A2=2*acos((r2*r2+d*d-r1*r1)/(2*r2*d));
	double s1=A1*r1*r1/2;
	double s2=A2*r2*r2/2;
	printf("%.3lf",s1+s2-s+1e-9);
	return 0;
} 
时间: 2024-08-10 19:18:45

poj 2546 Circular Area 两圆面积交的相关文章

poj 2546 Circular Area (两圆相交面积)

链接:poj 2546 题意:已知两圆的圆心和半径,求两圆相交部分的面积 分析:两圆的位置关系有三种:相离,相交,内含 相离时:相交面积为0 相交时,大扇形面积+小扇形面积-四边形面积 内含时,相交面积为小圆面积 #include<stdio.h> #include<math.h> #define PI acos(-1.0) typedef struct stu { double x,y; }point; double Distance(point a,point b) { ret

POJ 2546 Circular Area(两个圆相交的面积)

题目链接 题意 : 给你两个圆的半径和圆心,让你求两个圆相交的面积大小. 思路 : 分三种情况讨论 假设半径小的圆为c1,半径大的圆为c2. c1的半径r1,圆心坐标(x1,y1).c2的半径r2,圆心坐标(x2,y2). d为两圆圆心连线的长度. 相交面积为S d=sqrt((x1-x2)^2+(y1-y2)^2) (1)如果r1+r2<=d 那么两圆相离,相交面积S=0 (2)如果r2-r1>=d 那么半径小的圆内含半径大的圆,那么相交面积为小圆的面积S=pi*r1*r1 (3)既非(1)

poj 2546 Circular Area

Description Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after decimal point. Input In the single line of input file there are space-separated real numbers x1 y

HDOJ 5120 Intersection 两圆面积交

两圆面积交.... Intersection Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 101    Accepted Submission(s): 38 Problem Description Matt is a big fan of logo design. Recently he falls in love with l

POJ 2546 &amp; ZOJ 1597 Circular Area 两圆的面积交

Circular Area Time Limit: 2 Seconds      Memory Limit: 65536 KB Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after decimal point. Input In the single line of in

poj 2546(两圆公共面积)

Circular Area Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5682   Accepted: 2225 Description Your task is to write a program, which, given two circles, calculates the area of their intersection with the accuracy of three digits after

POJ 1265:Area

Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4725   Accepted: 2135 Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new resear

poj 3335 Rotating Scoreboard(半平面交)

Rotating Scoreboard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6420   Accepted: 2550 Description This year, ACM/ICPC World finals will be held in a hall in form of a simple polygon. The coaches and spectators are seated along the ed

POJ 1474 多边形的核(半平面交)

Video Surveillance Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3145   Accepted: 1391 Description A friend of yours has taken the job of security officer at the Star-Buy Company, a famous depart- ment store. One of his tasks is to ins