Circle Through Three Points
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4112   Accepted: 1712

Description

Your team is to write a program that, given the Cartesian coordinates of three points on a plane, will find the equation of the circle through them all. The three points will not be on a straight line.


The solution is to be printed as an equation of the form
	(x - h)^2 + (y - k)^2 = r^2				(1)

and an equation of the form

	x^2 + y^2 + cx + dy - e = 0				(2)

Input

Each line of input to your program will contain the x and y coordinates of three points, in the order Ax, Ay, Bx, By, Cx, Cy. These coordinates will be real numbers separated from each other by one or more spaces.

Output

Your program must print the required equations on two lines using the format given in the sample below. Your computed values for h, k, r, c, d, and e in Equations 1 and 2 above are to be printed with three digits after
the decimal point. Plus and minus signs in the equations should be changed as needed to avoid multiple signs before a number. Plus, minus, and equal signs must be separated from the adjacent characters by a single space on each side. No other spaces are to
appear in the equations. Print a single blank line after each equation pair.

Sample Input

7.0 -5.0 -1.0 1.0 0.0 -6.0
1.0 7.0 8.0 6.0 7.0 -2.0

Sample Output

(x - 3.000)^2 + (y + 2.000)^2 = 5.000^2
x^2 + y^2 - 6.000x + 4.000y - 12.000 = 0 (x - 3.921)^2 + (y - 2.447)^2 = 5.409^2
x^2 + y^2 - 7.842x - 4.895y - 7.895 = 0
直接推公式计算,推导时细心些,不然debug很累。。

#include<stdio.h>
#include<math.h>
int main()
{
double x1,x2,x3,y1,y2,y3;
while (~scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3))
{
double R;
double x, y;
double A1 = (x1+x2)/2, B1 = (y1+y2)/2, C1 = (x2-x1)/(y1-y2),
A2 = (x2+x3)/2, B2 = (y2+y3)/2, C2 = (x3-x2)/(y2-y3);
x = (B2-B1+A1*C1-A2*C2)/(C1-C2);
y = C1*(x-A1)+B1;
R = sqrt((x1 - x)*(x1 - x) + (y1 - y)*(y1 - y)); if (x>0)printf("(x - %.3lf)^2 + ", x); else printf("(x + %.3lf)^2 + ", x*(-1));
if (y>0)printf("(y - %.3lf)^2 = %.3f^2\n", y, R); else printf("(y + %.3lf)^2 = %.3f^2\n", y*(-1), R);
printf("x^2 + y^2 ");
if (x>0)printf("- %.3lfx ",x * 2); else printf("+ %.3lfx ", x*(-2));
if (y>0)printf("- %.3lfy ",y * 2); else printf("+ %.3lfy ", y*(-2));
double M = x*x + y*y - R*R;
if (M>0)printf("+ %.3lf = 0\n\n", M); else printf("- %.3lf = 0\n\n", M*(-1)); //puts("");
}
return 0;
}
												

POJ - 1329 Circle Through Three Points 求圆的更多相关文章

  1. poj 1329 Circle Through Three Points(求圆心+输出)

    题目链接:http://poj.org/problem?id=1329 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...

  2. ●POJ 1329 Circle Through Three Points

    题链: http://poj.org/problem?id=1329 题解: 计算几何,求过不共线的三点的圆 就是用向量暴力算出来的东西... (设出外心M的坐标,由于$|\vec{MA}|=|\ve ...

  3. POJ 1329 Circle Through Three Points(三角形外接圆)

    题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...

  4. POJ 1329 Circle Through Three Points(三角形外心)

    题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...

  5. poj 1329(已知三点求外接圆方程.)

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3766   Acce ...

  6. UVALive 4639 && SPOJ SPOINTS && POJ 3805 && AOJ 1298 Separate Points 求两个凸包是否相交 难度:3

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  7. poj1329 Circle Through Three Points

    地址:http://poj.org/problem?id=1329 题目: Circle Through Three Points Time Limit: 1000MS   Memory Limit: ...

  8. JAVA求圆的面积

    import java.text.DecimalFormat;import java.util.Scanner; public class TheAreaOfCircle { public stati ...

  9. POJ 1329 三角外接圆

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3169   Acce ...

随机推荐

  1. TPL概要

    ReaderWriterLockSlim.读写锁,允许多个线程同时获取读锁,但同一时间只允许一个线程获得写锁,因此也称作共享-独占锁.只有等到对象被写入锁占用的时候,才会阻塞 Barrier .它允许 ...

  2. Python核心编程——Chapter9

    好久没写过Python了,前一阵子忙这忙那的,都几乎把Python给丢掉了,话不多说,马上开始. 9.1.文件过滤.显示一个文件的所有行,并且忽略以井号开头的行. 其实这个题目比较基础,用shell语 ...

  3. 基本控件文档-UISwitch属性

    CHENYILONG Blog 基本控件文档-UISwitch属性 Fullscreen     UISwitch属性 技术博客http://www.cnblogs.com/ChenYilong/ 新 ...

  4. JS比较两个数字大小

    js不能直降比较两·个数大小,要先转化为整数再比较大小. parseInt()转化. 出处:http://www.jb51.net/article/98251.htm

  5. STL-set and multiset

    ! ! ! ! set 中的元素总是保持单调递增. set<int> a; set的插入 set没有尾部插入函数push_back(),元素的插入一般使用insert进行动态检索插入. a ...

  6. vue_router 动态路由

    配置子路由: 路由的视图都需要使用view-router 子路由也可以嵌套路由使用: children来做嵌套如上图 使用location.页面name就可以做页面跳转 mounted:挂载,延迟跳转 ...

  7. [译] 用HTML5捕获音频和视频

    原文地址:http://www.html5rocks.com/en/tutorials/getusermedia/intro/ 概述 有了HTML5,我们就可以在不借助Flash或者Silverlig ...

  8. VUE项目用hbuilder 打包为手机APP

    一.测试项目是否可以正确运行    指令:npm run dev 首先我们先建立一个vue的项目,本人用的是vue-cli随便建立的,然后运行项目 不必非得是像我这样的,这一步的目的只是测试一下咱们的 ...

  9. css的盒模型手机端兼容写法应该是啥样的呢?

    前言:刚刚接触css3的盒模型,感觉对于解决水平垂直居中.固定宽度/高度和可变宽度/高度同时存在这样的问题很有效.但是最近在看一个腾讯手机端框架(Frozen UI )的时候发现一个很神奇的多行文字截 ...

  10. java 面试算法题

    /** * 设有n个人依围成一圈,从第1个人开始报数,数到第m个人出列,然后从 * 出列的下一个人开始报数,数到第m个人又出列,…,如此反复到所有的人全部出列为 * 止.设n个人的编号分别为1,2,… ...