F - The Circumference of the Circle

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 <iostream>
#include<iomanip>
#include <cmath>
using namespace std;
#define PI 3.141592653589793
int main()
{
    double x1,y1,x2,y2,x3,y3;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3){
        double l,a1,b1,a2,b2,k1,k2,a,b;
        a1=x1/2+x2/2;
        a2=x1/2+x3/2;
        b1=y1/2+y2/2;
        b2=y1/2+y3/2;
        if(y1!=y2&&y3!=y1){
        k1=(x1-x2)/(y2-y1);
        k2=(x1-x3)/(y3-y1);
        a=(k1*a1-k2*a2+b2-b1)/(k1-k2);
        b=k1*(a-a1)+b1;
        }
        else if(y1==y2){
            k2=(x1-x3)/(y3-y1);
            a=(x1+x2)/2;
            b=k2*(a-a2)+b2;
        }
        else {
            k1=(x1-x2)/(y2-y1);
            a=(x1+x3)/2;
            b=k1*(a-a1)+b1;
        }
        l=2*PI*sqrt((a-x1)*(a-x1)+(b-y1)*(b-y1));
        cout.precision(2);
        cout.setf(ios::fixed);
        cout<<l<<endl;
    }
    //system("pause");
    return 0;
}
时间: 2024-10-05 11:34:24

F - The Circumference of the Circle的相关文章

【POJ2242】The Circumference of the Circle(初等几何)

已知三点坐标,算圆面积. 使用初等几何知识,根据海伦公式s = sqrt(p(p - a)(p - b)(p - c)) 和 外接圆直径 d = a * b * c / (2s) 来直接计算. 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #include <numeric> 6 #include <cctype&g

poj 2242 The Circumference of the Circle

题目大意:给出三个点的坐标,求三点组成的三角形的外接圆的周长,假设已知三角形边长a,b,c和三角形面积s,则外接圆直径 d = (a*b*c)/(2*s) #include <iostream> #include <cmath> #include <iomanip> using namespace std; const double pi=3.141592653589793; int main() { double x1,y1,x2,y2,x3,y3,a,b,c,st,

H - Ones

Description Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n? Input Each line contains a number n. Outp

[Catalan数]1086 栈、3112 二叉树计数、3134 Circle

1086 栈 2003年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表. 栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈). 栈的重要性不言自明,任何一门数据结构的课程都会介绍栈.宁宁同学在复习栈的基本概念时,想到了一个书上没有讲过的问题,而他自己无法给出答案,所以需要你的帮忙 宁宁考虑的

[Swift]LeetCode478. 在圆内随机生成点 | Generate Random Point in a Circle

Given the radius and x-y positions of the center of a circle, write a function randPoint which generates a uniform random point in the circle. Note: input and output values are in floating-point. radius and x-y position of the center of the circle is

数学符号π (Pi)、Σ(Sigma)的来历

一.π (Pi) March 14 marks Pi Day, the holiday commemorating the mathematical constant π (pi), written numerically as 3.141592+. Since mathematic notation is a language that uses symbols from a multitude of alphabets and typefaces, it seems only fitting

第11本:历史上最伟大的10个方程

第11本:历史上最伟大的10个方程 看此书的主要目的是想了解欧拉公式这个最美的上帝公式的含义,后面的公式越来越难,基本上就不仔细看了. 1.毕达哥拉斯定理(勾股定理)c2=a2+b2 下面这张图是欧几里得<几何原本>中的一个证明的经典图形. 在这个网站http://www.cut-the-knot.org/pythagoras/index.shtml中给出了100多种证明方法,谁有耐心看完,估计几何就学好了. 2.牛顿第二定律F=ma 高一物理课本一上来就讲这个著名的定理. 3.牛顿万有引力定

(转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!

ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO http://ace.delos.com/usacogate 美国著名在线题库,专门为信息学竞赛选手准备 TJU http://acm.tongji.edu.cn/ 同济大学在线题库,唯一的中文题库,适合NOIP选手 ZJU http://acm.zju.edu.cn/ 浙江大学在线题库 JLU htt

读书笔记2014第11本:历史上最伟大的10个方程

看此书的主要目的是想了解欧拉公式这个最美的上帝公式的含义,后面的公式越来越难,基本上就不仔细看了. 1.毕达哥拉斯定理(勾股定理)c2=a2+b2 下面这张图是欧几里得<几何原本>中的一个证明的经典图形. 在这个网站http://www.cut-the-knot.org/pythagoras/index.shtml中给出了100多种证明方法,谁有耐心看完,估计几何就学好了. 2.牛顿第二定律F=ma 高一物理课本一上来就讲这个著名的定理. 3.牛顿万有引力定律Fg=Gm1m2/r2 牛顿的苹果