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. 3687: 简单题(bitset)

    3687: 简单题 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 700  Solved: 319[Submit][Status][Discuss] ...

  2. 算法:枚举法---kotlin

    枚举法:效率低,循环所有的情况,找到正确答案 用于解决数学问题,还是很简单的. 比如,奥数里面: 算 法 描 述 题X题=题题题题题题 其中 算法描述题每一个为一个数字,请写出正确的数字. ok,我们 ...

  3. centos 服务器内存管理 服务于端口状态

    du su /目录/ 查看改目录大小 ls -lht /  查看文件详情,显示文件大小(直观) df -h 查看系统内存占用情况 centos 版本 lsb_release -a cat /etc/i ...

  4. 了解JavaScript核心精髓(四)

    ES6 1.import与require区别 import 是同步导入js模块. require 是异步导入js模块. 2.使用let与const let con1 = 3 //与var作用相似,le ...

  5. UIAutomator2、Appium、Robotium搭建环境与框架对比

    UIAutomator2.Appium.Robotium搭建环境与框架对比 一.框架介绍 Appium 特点 appium 是一个自动化测试开源工具,支持 iOS 平台和 Android 平台上的原生 ...

  6. ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

    这是在python中使用caffe产生的错误. 程序很普通: #-*-coding=utf-8-*- import numpy as npimport matplotlib.pyplot as plt ...

  7. React01补充

    使用yarn安装脚手架 npm i -g yarn npm uninstall -g create-react-app yarn global add create-react-app create- ...

  8. EXTJS4.0 grid 可编辑模式 配置

    首先配置这个参数 plugins:[//插件 Ext.create("Ext.grid.plugin.CellEditing",{ clicksToEdit:1//单元格 点一下就 ...

  9. 【bzoj4756】[Usaco2017 Jan]Promotion Counting 离散化+树状数组

    原文地址:http://www.cnblogs.com/GXZlegend/p/6832263.html 题目描述 The cows have once again tried to form a s ...

  10. [bzoj] 1036 Count

    原题 树链剖分板子题 树剖详解: #include<cstdio> #include<algorithm> typedef long long ll; #define N 30 ...