POJ 2242 The Circumference of the Circle:计算几何

The Circumference of the Circle

http://poj.org/problem?id=2242

Time Limit: 1000MS

Memory Limit: 65536K

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

Source

Ulm Local 1996

S=(a*b*sinC)/2

c/sinC=外接圆直径d

d=(a*b*c)/(2*S)

S由有向面积(行列式)得出

注意:POJ上的C++不支持C99,但G++支持

完整代码:

/*0ms,588KB*/

#include<cstdio>
#include<cmath>
const double PI = acos(-1.0);  

inline double area(double x0, double y0, double x1, double y1, double x2, double y2)
{
    return fabs(x0 * y1 + x2 * y0 + x1 * y2 - x2 * y1 - x0 * y2 - x1 * y0);
}  

int main(void)
{
    double x0, y0, x1, y1, x2, y2;
    while (~scanf("%lf%lf%lf%lf%lf%lf", &x0, &y0, &x1, &y1, &x2, &y2))
        printf("%.2f\n", hypot(x0 - x1, y0 - y1) * hypot(x1 - x2, y1 - y2) * hypot(x0 - x2, y0 - y2) * PI / area(x0, y0, x1, y1, x2, y2));
    return 0;
}

查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索double
, c++ poj
, c++ 编程 poj
, of
, The
, 1.0
Three
circumference、waist circumference、hem circumference、head circumference、circumference 可数,以便于您获取更多的相关知识。

时间: 2024-09-13 00:08:27

POJ 2242 The Circumference of the Circle:计算几何的相关文章

UVa 438 The Circumference of the Circle (计算几何)

438 - The Circumference of the Circle Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=379 To calculate the circumference of a circle seems to be an easy t

ZOJ 1090 - The Circumference of the Circle 解题报告

      题目的链接在这里:       http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1090       题目描述很简单,大意是,给出三个点的坐标,设为A(x1,y1),B (x2, y2),C (x3, y3),然后求出通过这三点的圆的周长(保留两位小数).但推导公式却比较麻烦,我是这样来做的.       首先根据同一个弦的圆心角角度相同,不难得出,圆周的直径d= BC/ sin a = AC/ sin b =

POJ 2606 / URAL 1502 Rabbit hunt:计算几何

1052. Rabbit Hunt http://poj.org/problem?id=2606 http://acm.timus.ru/problem.aspx?space=1&num=1052 Time limit: 1.0 second Memory limit: 64 MB A good hunter kills two rabbits with one shot. Of course, it can be easily done since for any two points we

POJ题目分类

初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:      (1)图的深度优先遍历和广度优先遍历.      (2)最短路径算法(dijkstra,bellman-ford

poj分类

初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:      (1)图的深度优先遍历和广度优先遍历.      (2)最短路径算法(dijkstra,bellman-ford

poj 题型分类

主流算法: 1.搜索 //回溯 2.DP(动态规划) 3.贪心 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同等安置矩形的并的面积与周长 7.组合数学 //Polya定理 8.模拟 9.数据结构 //并查集.堆 10.博弈论 1. 排序 1423, 1694, 1723, 1727, 1763, 1788, 1828, 1838, 1840, 2201, 2376, 2377, 2380, 1318, 1877, 1928, 1971,

hduoj题目分类

基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093.1094.1095.1096.1097.1098.1106.1108.1157.1163.1164.1170.1194.1196.1197.1201.1202.1205.1219.1234.1235.1236.1248.1

ACM练级

一般要做到50行以内的程序不用调试.100行以内的二分钟内调试成功.acm主要是考算法的 ,主要时间是花在思考算法上,不是花在写程序与debug上.  下面给个计划你练练: 第一阶段: 练经典常用算法,下面的每个算法给我打上十到二十遍,同时自己精简代码, 因为太常用,所以要练到写时不用想,10-15分钟内打完,甚至关掉显示器都可以把程序打 出来.  1.最短路(Floyd.Dijstra,BellmanFord)  2.最小生成树(先写个prim,kruscal要用并查集,不好写)  3.大数(

英国科学期刊选出了世界上最美丽的10个公式

◆ ◆ ◆ 导言 英国科学期刊<物理世界>曾让读者投票评选了"最伟大的公式",最终榜上有名的十个公式既有无人不知的1+1=2,又有著名的E=mc2:既有简单的圆周公式,又有复杂的欧拉公式--从什么时候起我们开始厌恶数学?这些东西原本如此美丽,如此精妙.这个地球上有多少伟大的智慧曾耗尽一生,才最终写下一个等号.每当你解不开方程的时候,不妨换一个角度想,暂且放下对理科的厌恶和对考试的痛恨.因为你正在见证的,是科学的美丽与人类的尊严. ◆ ◆ ◆ 圆的周长公式(The Lengt