poj 2242(已知三点求外接圆周长)

The Circumference of the Circle

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8310   Accepted: 4960

Description

To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don‘t?

You are given the cartesian coordinates of three non-collinear points in the plane.

Your job is to calculate the circumference of the unique circle that intersects all three points.

Input

The
input will contain one or more test cases. Each test case consists of
one line containing six real numbers x1,y1, x2,y2,x3,y3, representing
the coordinates of the three points. The diameter of the circle
determined by the three points will never exceed a million. Input is
terminated by end of file.

Output

For
each test case, print one line containing one real number telling the
circumference of the circle determined by the three points. The
circumference is to be printed accurately rounded to two decimals. The
value of pi is approximately 3.141592653589793.

Sample Input

0.0 -0.5 0.5 0.0 0.0 0.5
0.0 0.0 0.0 1.0 1.0 1.0
5.0 5.0 5.0 7.0 4.0 6.0
0.0 0.0 -1.0 7.0 7.0 7.0
50.0 50.0 50.0 70.0 40.0 60.0
0.0 0.0 10.0 0.0 20.0 1.0
0.0 -500000.0 500000.0 0.0 0.0 500000.0

Sample Output

3.14
4.44
6.28
31.42
62.83
632.24
3141592.65
开始准备用二分去找的...然后忘了外接圆的定义,然后百度,,发现直接有公式这里是外接圆半径公式

外接圆:

下面是公式推导:

海伦公式

内切圆:

海伦公式可知,

解得

#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double pi =  3.141592653589793;
const double esp = 1e-8;
struct Point{
    double x,y;
}p[3];
double dis(Point a,Point b){
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

int main()
{

    while(scanf("%lf%lf%lf%lf%lf%lf",&p[0].x,&p[0].y,&p[1].x,&p[1].y,&p[2].x,&p[2].y)!=EOF){
        double a = sqrt(dis(p[0],p[1]));
        double b = sqrt(dis(p[1],p[2]));
        double c = sqrt(dis(p[0],p[2]));
        double r = a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
        printf("%.2lf\n",2*pi*r);
    }
    return 0;
}

				
时间: 2024-10-10 20:29:32

poj 2242(已知三点求外接圆周长)的相关文章

poj 1329(已知三点求外接圆方程.)

Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3766   Accepted: 1570 Description Your team is to write a program that, given the Cartesian coordinates of three points on a plane, will find the equation of the

已知三点求圆心与半径

已知三点求圆心与半径  [email protected] http://blog.csdn.net/kezunhai 在计算机图像图形学中,经常会用到求圆心或圆半径的情况,本文介绍一种已知三个点求圆心和圆半径的方法(当然三个点不能共线,共线的三个点不能构成圆). 原理:相互连接三个点,选取其中的任意两条直线,通过对这两条直线的中心做垂线,两条垂线的交点就是圆心,以此点为圆心,以此点到任意一点的距离为半径画圆. 三个点分别计为pt1, pt2, pt3:取直线p1p2和p1p3(也可以取其他直线

已知矩形面积求最小周长

Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows the area of this paper, he wants to know the minimum perimeter of this paper. Input In the first line, there is an integer T indicates the number of te

Scala实现:已知三点坐标,求最短距离(如果在垂足不在线段内,最短距离为到其中一点的直线距离)

/** * 已知三点坐标,求其中一点到另两点的垂线距离 * (如果在垂足不在线段内,最短距离为到其中一点的直线距离) * Created by wzq on 17-11-2. */object Point2lineDistance { def main(args: Array[String]) { val v: Double = pointToLine(-3, 0, 3, 0, 0, 3) System.out.println(v) } def pointToLine(x1: Int, y1:

POJ 2208 已知空间四面体六条边长度,求体积

Pyramids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2718   Accepted: 886   Special Judge Description Recently in Farland, a country in Asia, a famous scientist Mr. Log Archeo has discovered ancient pyramids. But unlike those in Egyp

poj 2002(好题 链式hash+已知正方形两点求另外两点)

Squares Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 18493   Accepted: 7124 Description A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating abou

Luogu-P1027 Car的旅行路线 已知三点确定矩形 + 最短路

传送门:https://www.luogu.org/problemnew/show/P1027 题意: 图中有n个城市,每个城市有4个机场在矩形的四个顶点上.一个城市间的机场可以通过高铁通达,不同城市间要通过飞机.现在问从s到t城市最少需要多少的费用. 思路: 已知矩形的三个顶点,可以用勾股定理确定斜边后,利用平行四边形原理——两对对角顶点的x之和是相同的,y之和也是相同的得到第四个顶点.然后用求最短路的dji即可. #include <algorithm> #include <iter

已知段地址,求CPU寻址范围

已知段地址为0001H,仅通过变化偏移地址寻址,则CPU的寻址范围是? 物理地址 = 段地址×16 + 偏移地址 所以物理地址的范围是[16×1H+0H, 16×1H+FFFFH] 也就是[10H×1H+0H, 10H×1H+FFFFH] 所以CPU的寻址范围是[10H, 1000FH] 原文地址:https://www.cnblogs.com/buyishi/p/10591351.html

已知三个点坐标,求由这三个点构成的多边形的最大面积。

给出A(x0, y0) B(x1, y1) C(x2, y2) 1.求3边a,b,c 2. 先求外接圆半径.(一定存在) 海伦公式 + 正弦定理   得  R = a * b * c / (4 * S)   S = sqrt(q * (q - a) * (q - b) * (q -c));  q = (a + b + c) / 2; -----因为是正多边形. 那么只要求出一边与两半径围成的面积 * N 就好. 3. 余弦定理 求3个角. 求最大公约数就是  正多边形 每一份   最小的角度.