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


求三角形外接圆周长:

设三角形三边长分别为a,b,ca,b,c,半周长为pp,面积为ss;外接圆半径为rr,周长为circir。

p=(a+b+c)/2p=(a+b+c)/2

海伦公式:s=(p∗(p−a)∗(p−b)∗(p−c)−−−−−−−−−−−−−−−−−−−−−−−√s=\sqrt{(p*(p-a)*(p-b)*(p-c)}

正弦定理:c/sinC=2rc/sinC=2r

又因为:s=(absinC)/2s=(absinC)/2

所以周长:
cir=2∗pi∗r=pi∗c/sin=(pi∗abc)/(2∗s)cir=2*pi*r=pi*c/sin=(pi*abc)/(2*s)

=(pi∗abc)/(2∗(p∗(p−a)∗(p−b)∗(p−c)−−−−−−−−−−−−−−−−−−−−−−−√)=(pi*abc)/(2*\sqrt{(p*(p-a)*(p-b)*(p-c)})


/*求三角形外接圆周长*/
#include<iostream>
#include<iomanip>
#include<math.h>using namespace std;#define PI 3.141592653589793double length(double x1,double y1,double x2,double y2)
{return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}int main()
{double x1, y1, x2, y2, x3, y3;double cir = 0;while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){double a = length(x1, y1, x2, y2);double b = length(x1, y1, x3, y3);double c = length(x2, y2, x3, y3);double p = (a + b + c) / 2;double s = sqrt(p*(p - a)*(p - b)*(p - c));cir = PI*a*b*c / (2 * s);cout << fixed << setprecision(2) << cir << endl;}return 0;
}

2242 The Circumference of the Circle相关推荐

  1. ZOJ 1090 The Circumference of the Circle(计算三角形的外接圆)

    提交地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1090 这是我最喜欢做的题之一,因为这种题我感觉 做一遍以后就会了 ...

  2. UVA 438 - The Circumference of the Circle

    题意:给出3点坐标,求过三点圆周长 解法:用海伦公式求出三角形面积s,因为s=(1/2)absin(a.b),且根据正弦定理,2r=c/sin(a.b),得圆半径 r=Πabc/(2s),进而解出圆周 ...

  3. 转载[POJ题型分类]

    北大ACM题分类 主流算法: 1.搜索 //回溯 2.DP(动态规划) 3.贪心 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同等安置矩形的 ...

  4. ACM 网址和一些建议

    USACO http://ace.delos.com/usacogate 美国著名在线题库,专门为信息学竞赛选手准备 TJU http://acm.tongji.edu.cn/ 同济大学在线题库,唯一 ...

  5. 【poj题集整理】【存下来并不会看】

    主要是整理起来自己用的.网上有多个版本. 初级: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)   ...

  6. (精)【ACM刷题之路】POJ题目详细多角度分类及推荐题目

    POJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094) 初期: ...

  7. 初学ACM之路(训练大纲)

    初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj329 ...

  8. ACM大量习题题库及建议培养计划

    ACM大量习题题库 ACM大量习题题库  现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO h ...

  9. ACM题目和培养训练!!!

    ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...

最新文章

  1. Java Nashorn--Part 3
  2. Kruskal算法的C语言程序
  3. JZOJ 1240. Fibonacci sequence
  4. 技术干货 | 为高音质保驾护航 - 通信中的回声消除
  5. angular 数字逗号分隔,如何在Angular 4中为数字管道指定区域设置千位分隔符
  6. 根据时间戳生成编号_分布式系统的唯一ID生成算法对比
  7. jquery datatable设置垂直滚动后,表头(th)错位问题
  8. c# uri.host_C#| Uri.FromHex()方法与示例
  9. Codeforces 776D The Door Problem
  10. [转]ASP.NET MVC HtmlHelper扩展之Calendar日期时间选择
  11. easyUI按钮图表对照大全
  12. [bzoj 4774]修路
  13. c语言编译为机器语言过程,C语言编译全过程
  14. 企业级实际性能测试案例与经验分享
  15. uvalive 3938 Ray, Pass me the dishes! 线段树 区间合并
  16. eoc机顶盒wifi服务器未响应,网络机顶盒中桌面配置服务器
  17. 雷赛服务器信号er020,雷赛机电 DMC2410高性能4轴运动控制卡 运动控制 产品 参数...
  18. c语言头文件及形式,C语言头文件作用及写法
  19. Python练习小工具——根据Exif的拍摄时间和设备名批量重命名照片
  20. word pdf 互转

热门文章

  1. EF Core反向工程
  2. BCGControlBar入门
  3. ajax-传递map集合,springboot接收参数
  4. 什么是 .NET Framework,使用者和开发者需要注意哪些
  5. extjs使用、总结、感悟
  6. 建模实训报告总结_3Dmax建模实习报告
  7. 小学计算机使用计划书,小学生学习计划书范文
  8. 100+队伍逐鹿大奖,创新编程挑战赛秋季赛圆满落幕
  9. 2012年敏捷个人俱乐部(北京)实践团开始报名了......
  10. 魔百和cm102晨星处理器机顶盒刷当贝桌面固件教程