Circle Through Three Points
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 3766   Accepted: 1570

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

Source

恶心的输出..看了discuss才知道0.000要原样输出。。

#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double pi = 3.141592653589793;
const double eps = 1e-;
struct Point
{
double x,y;
} p[];
double dis(Point a,Point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
///外接圆圆心坐标
Point waixin(Point a,Point b,Point c)
{
Point p;
double a1 = b.x - a.x, b1 = b.y - a.y, c1 = (a1*a1 + b1*b1)/;
double a2 = c.x - a.x, b2 = c.y - a.y, c2 = (a2*a2 + b2*b2)/;
double d = a1*b2 - a2*b1;
p.x = a.x + (c1*b2 - c2*b1)/d, p.y=a.y + (a1*c2 -a2*c1)/d;
return p;
}
char check(double x)
{
if(x<-eps) return '+';
return '-';
}
char check2(double x)
{
if(x<-eps) return '-';
return '+';
}
int main()
{ while(scanf("%lf%lf%lf%lf%lf%lf",&p[].x,&p[].y,&p[].x,&p[].y,&p[].x,&p[].y)!=EOF)
{
double a = dis(p[],p[]);
double b = dis(p[],p[]);
double c = dis(p[],p[]);
double r = a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
Point center;
center = waixin(p[],p[],p[]);
if(fabs(center.x)<eps) printf("x^2 + ");
else printf("(x %c %.3lf)^2 + ",check(center.x),fabs(center.x));
if(fabs(center.y)<eps) printf("y^2");
else printf("(y %c %.3lf)^2",check(center.y),fabs(center.y));
printf(" = %.3lf^2\n",r); printf("x^2 + y^2");
double c1 = *center.x,d1=*center.y;
double r1 = center.x*center.x+center.y*center.y-r*r;
printf(" %c %.3lfx %c %.3lfy %c %.3lf = 0\n\n",check(c1),fabs(c1),check(d1),fabs(d1),check2(r1),fabs(r1));
}
return ;
}

poj 1329(已知三点求外接圆方程.)的更多相关文章

  1. poj 2242(已知三点求外接圆周长)

    The Circumference of the Circle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8310   ...

  2. 2020牛客暑期多校训练营 第二场 B Boundary 计算几何 圆 已知三点求圆心

    LINK:Boundary 计算几何确实是弱项 因为好多东西都不太会求 没有到很精通的地步. 做法很多,先说官方题解 其实就是枚举一个点 P 然后可以发现 再枚举一个点 然后再判断有多少个点在圆上显然 ...

  3. 【NX二次开发】三点画圆,三角形外心,已知三点求圆心

    已知P1.P2.P3,求点O 算法:三点不在一条直线上时,通过连接任意两点,作中垂线.任意两条中垂线的交点是圆心.

  4. poj 2002(好题 链式hash+已知正方形两点求另外两点)

    Squares Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 18493   Accepted: 7124 Descript ...

  5. Luogu-P1027 Car的旅行路线 已知三点确定矩形 + 最短路

    传送门:https://www.luogu.org/problemnew/show/P1027 题意: 图中有n个城市,每个城市有4个机场在矩形的四个顶点上.一个城市间的机场可以通过高铁通达,不同城市 ...

  6. [YY]已知逆序列求原序列(二分,树状数组)

    在看组合数学,看到逆序列这个概念.于是YY了一道题:已知逆序列,求出原序列. 例子: 元素个数 n = 8 逆序列 a={5,3,4,0,2,1,1,0} 则有原序列 p={4,8,6,2,5,1,3 ...

  7. 已知段地址,求CPU寻址范围

    已知段地址为0001H,仅通过变化偏移地址寻址,则CPU的寻址范围是? 物理地址 = 段地址×16 + 偏移地址 所以物理地址的范围是[16×1H+0H, 16×1H+FFFFH] 也就是[10H×1 ...

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

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

  9. POJ 2208 已知边四面体六个长度,计算体积

    Pyramids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2718   Accepted: 886   Special ...

随机推荐

  1. 非阻塞IO模板

    服务端 from socke import * server = socket(AF_INET, SOCK_STREAM) server.bind(('127.0.0.1',8083)) server ...

  2. HTTP的缓存控制

    1.缓存的分类: (1)缓存分为服务端侧(server side,比如 Nginx.Apache)和客户端侧(client side,比如 web browser). (2)服务端缓存又分为 代理服务 ...

  3. (B)springboot配置开发和测试环境并添加启动路径

    嗯,开发和测试环境要分离,这是一般共识(虽然我工作过的公司都没有这种分离),spring boot也可以按照配置文件的读取来做到这一点. 上图有三个application开头的配置文件,要达到能够读取 ...

  4. 【Theory of Generalization】林轩田机器学习基石

    紧接上一讲的Break Point of H.有一个非常intuition的结论,如果break point在k取到了,那么k+1, k+2,... 都是break point. 那么除此之外,我们还 ...

  5. linux下给开启端口

    首先在这里要推荐一篇博文 http://blog.csdn.net/zht666/article/details/17505789 这篇文章写的很详细,里面包含了操作端口一些命令,我们操作端口其实就是 ...

  6. ASP.NET Core [1]:Hosting(笔记)

    参考:http://www.cnblogs.com/RainingNight/p/hosting-in-asp-net-core.html

  7. Unresolved defparam reference to 'read_aclr_synch' in dcfifo_component.read_aclr_synch

    问题: 今天用 questasim 仿真出现下面这个问题. Unresolved defparam reference to 'read_aclr_synch' in dcfifo_component ...

  8. ocrosoft Contest1316 - 信奥编程之路~~~~~第三关 问题 E: IQ(iq)

    http://acm.ocrosoft.com/problem.php?cid=1316&pid=4 题目描述 根据世界某权威学会的一项调查,学信息学的学生IQ非常高.举个最好的例子,如果我们 ...

  9. 【bzoj1899】[Zjoi2004]Lunch 午餐 dp

    题目描述 上午的训练结束了,THU ACM小组集体去吃午餐,他们一行N人来到了著名的十食堂.这里有两个打饭的窗口,每个窗口同一时刻只能给一个人打饭.由于每个人的口味(以及胃口)不同,所以他们要吃的菜各 ...

  10. hdu 1172 猜数字

    猜数字 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...