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

  1. 0.0 -0.5 0.5 0.0 0.0 0.5
  2. 0.0 0.0 0.0 1.0 1.0 1.0
  3. 5.0 5.0 5.0 7.0 4.0 6.0
  4. 0.0 0.0 -1.0 7.0 7.0 7.0
  5. 50.0 50.0 50.0 70.0 40.0 60.0
  6. 0.0 0.0 10.0 0.0 20.0 1.0
  7. 0.0 -500000.0 500000.0 0.0 0.0 500000.0

Sample Output

  1. 3.14
  2. 4.44
  3. 6.28
  4. 31.42
  5. 62.83
  6. 632.24
  7. 3141592.65
  1. #include <iostream>
  2. #include<iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. #define PI 3.141592653589793
  6. int main()
  7. {
  8. double x1,y1,x2,y2,x3,y3;
  9. while(cin>>x1>>y1>>x2>>y2>>x3>>y3){
  10. double l,a1,b1,a2,b2,k1,k2,a,b;
  11. a1=x1/+x2/;
  12. a2=x1/+x3/;
  13. b1=y1/+y2/;
  14. b2=y1/+y3/;
  15. if(y1!=y2&&y3!=y1){
  16. k1=(x1-x2)/(y2-y1);
  17. k2=(x1-x3)/(y3-y1);
  18. a=(k1*a1-k2*a2+b2-b1)/(k1-k2);
  19. b=k1*(a-a1)+b1;
  20. }
  21. else if(y1==y2){
  22. k2=(x1-x3)/(y3-y1);
  23. a=(x1+x2)/;
  24. b=k2*(a-a2)+b2;
  25. }
  26. else {
  27. k1=(x1-x2)/(y2-y1);
  28. a=(x1+x3)/;
  29. b=k1*(a-a1)+b1;
  30. }
  31. l=*PI*sqrt((a-x1)*(a-x1)+(b-y1)*(b-y1));
  32. cout.precision();
  33. cout.setf(ios::fixed);
  34. cout<<l<<endl;
  35. }
  36. //system("pause");
  37. return ;
  38. }

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

  1. poj 1090:The Circumference of the Circle(计算几何,求三角形外心)

    The Circumference of the Circle Time Limit: 2 Seconds      Memory Limit: 65536 KB To calculate the c ...

  2. ZOJ Problem Set - 1090——The Circumference of the Circle

      ZOJ Problem Set - 1090 The Circumference of the Circle Time Limit: 2 Seconds      Memory Limit: 65 ...

  3. ZOJ 1090 The Circumference of the Circle

    原题链接 题目大意:已知三角形的三个顶点坐标,求其外接圆的周长. 解法:刚看到这道题时,马上拿出草稿纸画图,想推导出重心坐标,然后求出半径,再求周长.可是这个过程太复杂了,写到一半就没有兴致了,还是求 ...

  4. POJ2242 The Circumference of the Circle(几何)

    题目链接. 题目大意: 给定三个点,即一个任意三角形,求外接圆的周长. 分析: 外接圆的半径可以通过公式求得(2*r = a/sinA = b/sinB = c/sinC),然后直接求周长. 注意: ...

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

    已知三点坐标,算圆面积. 使用初等几何知识,根据海伦公式s = sqrt(p(p - a)(p - b)(p - c)) 和 外接圆直径 d = a * b * c / (2s) 来直接计算. #in ...

  6. POJ 2242 The Circumference of the Circle

    做题回顾:用到海伦公式,还有注意数据类型,最好统一 p=(a+b+c)/2; s=sqrt(p*(p-a)*(p-b)*(p-c));//三角形面积,海伦公式 r=a*b*c/(4*s);//这是外接 ...

  7. H - Ones

    Description Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a ...

  8. [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 gener ...

  9. [LeetCode] Generate Random Point in a Circle 生成圆中的随机点

    Given the radius and x-y positions of the center of a circle, write a function randPoint which gener ...

随机推荐

  1. 判断两个View的GRect是否相等

    if (CGRectEqualToRect(self.view.frame, rect)) { // do some stuff }

  2. After a rest, go on

    busy during the whole May holiday. running between S and H, waste much time leaving things behind. t ...

  3. 通过startup启动tomcat一闪而过的问题

    下载了免安装版的tomcat7,在通过startup.bat启动时,控制台一闪而过.记事本讲startup.bat打开,在最后一行加上pause,然后重新双击startup.bat,发现控制台打印的错 ...

  4. 如何中途停止RMAN备份任务

    问题背景 如果,你负责的数据库服务器,在RMAN进行全备时,业务又有大量数据要处理,一时间,系统资源直接被耗尽,影响到了业务的正常,你准备怎么处理? 解决办法 [不推荐]当时我们组的另外一个同事在没有 ...

  5. No1_4.数组的基本操作_Java学习笔记

    import java.util.Arrays; public class HelloArrayOp { public static void main(String[] args) { // TOD ...

  6. export-data.js

    var timeBtnClick = (function() { function _todayClick() { $('.select-time .today').on('click', funct ...

  7. 使用Genymotion调试出现错误INSTALL_FAILED_CPU_ABI_INCOMPATIBLE解决办法【转自wjr2012的csdn blog】

    点击下载Genymotion-ARM-Translation.zip 将你的虚拟器运行起来,将下载好的zip包用鼠标拖到虚拟机窗口中,出现确认对跨框点OK就行.然后重启你的虚拟机.

  8. 我是菜鸟,我怕谁--hdu2520

    我是菜鸟,我怕谁 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  9. mysql 在启动时配置文件的查找方式

    知识储备: 1.mysql在启动时会去多个地方找它的配置文件,当然啦这些也都是可以从帮助中找到的,问题在于我们要知道怎么找到对应的帮助才行啊 实战: [root@workstudio data]# m ...

  10. Git工作中用法(Gitlab)

    感觉又有了新的认识.  一共有3个仓库,本地自己的,远程自己的,远程主仓库. 为了方便能及时从主仓库获取更新的内容要将远程主仓库也clone下来 git clone upstream url    / ...