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 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 Specification

The input file will contain one or more test cases. Each test case consists of one line containing six real numbers 计算几何)-circumference">

, 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 Specification

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

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

R=abc/(4S)

完整代码:

/*0.018s*/

#include<cstdio>
#include<cmath>
const double pi = 2 * acos(0);  

int main()
{
    double x1, y1, x2, y2, x3, y3, xx1, yy1, xx2, yy2, xx3, yy3;
    while (~scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3))
    {
        xx1 = x2 - x1, yy1 = y2 - y1, xx2 = x3 - x1, yy2 = y3 - y1, xx3 = x3 - x2, yy3 = y3 - y2;
        printf("%.2f\n", pi * hypot(xx1, yy1)*hypot(xx2, yy2)*hypot(xx3, yy3) / fabs(xx1 * yy2 - xx2 * yy1));
    }
    return 0;
}

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

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

时间: 2024-10-06 01:28:17

UVa 438 The Circumference of the Circle (计算几何)的相关文章

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 gi

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 =

UVa 143 Orchard Trees:数学&amp;amp;计算几何&amp;amp;枚举

143 - Orchard Trees Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=79 An Orchardist has planted an orchard in a rectangle with trees uniformly spaced in both directions.

UVa 10112 Myacm Triangles:枚举&amp;amp;计算几何

10112 - Myacm Triangles Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=101&page=show_problem&problem=1053 计算几何-puzzle acm uva227">There has been considerable archeological wo

UVa 10250 The Other Two Trees:计算几何

10250 - The Other Two Trees Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=101&page=show_problem&problem=1191 You have a quadrilateral shaped land whose opposite fences are of equal

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

ACM练级

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

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,