poj 1329(已知三点求外接圆方程.)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 3766 | Accepted: 1570 |
Description
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
Output
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(已知三点求外接圆方程.)的更多相关文章
- poj 2242(已知三点求外接圆周长)
The Circumference of the Circle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8310 ...
- 2020牛客暑期多校训练营 第二场 B Boundary 计算几何 圆 已知三点求圆心
LINK:Boundary 计算几何确实是弱项 因为好多东西都不太会求 没有到很精通的地步. 做法很多,先说官方题解 其实就是枚举一个点 P 然后可以发现 再枚举一个点 然后再判断有多少个点在圆上显然 ...
- 【NX二次开发】三点画圆,三角形外心,已知三点求圆心
已知P1.P2.P3,求点O 算法:三点不在一条直线上时,通过连接任意两点,作中垂线.任意两条中垂线的交点是圆心.
- poj 2002(好题 链式hash+已知正方形两点求另外两点)
Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 18493 Accepted: 7124 Descript ...
- Luogu-P1027 Car的旅行路线 已知三点确定矩形 + 最短路
传送门:https://www.luogu.org/problemnew/show/P1027 题意: 图中有n个城市,每个城市有4个机场在矩形的四个顶点上.一个城市间的机场可以通过高铁通达,不同城市 ...
- [YY]已知逆序列求原序列(二分,树状数组)
在看组合数学,看到逆序列这个概念.于是YY了一道题:已知逆序列,求出原序列. 例子: 元素个数 n = 8 逆序列 a={5,3,4,0,2,1,1,0} 则有原序列 p={4,8,6,2,5,1,3 ...
- 已知段地址,求CPU寻址范围
已知段地址为0001H,仅通过变化偏移地址寻址,则CPU的寻址范围是? 物理地址 = 段地址×16 + 偏移地址 所以物理地址的范围是[16×1H+0H, 16×1H+FFFFH] 也就是[10H×1 ...
- poj 1329 Circle Through Three Points(求圆心+输出)
题目链接:http://poj.org/problem?id=1329 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...
- POJ 2208 已知边四面体六个长度,计算体积
Pyramids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2718 Accepted: 886 Special ...
随机推荐
- P3818 小A和uim之大逃离 II(洛谷月赛)
P3818 小A和uim之大逃离 II 题目背景 话说上回……还是参见 https://www.luogu.org/problem/show?pid=1373 吧 小a和uim再次来到雨林中探险.突然 ...
- 《Cracking the Coding Interview》——第17章:普通题——题目11
2014-04-29 00:00 题目:给定一个rand5()函数,能够返回0~4间的随机整数.要求实现rand7(),返回0~6之间的随机整数.该函数产生随机数必须概率相等. 解法:自己想了半天没想 ...
- DWZ(J-UI)之路:错误
1:关于左侧点击会把右边小窗口替换掉,导致右边永远只有一个小窗口. 方法:因为缺少了这个—— <li><a href="/admin/demo/index" ta ...
- 剖析epool
[01]什么是epool: 当互联网的用户越来越多的时候,人们发现传统的网络io模型,扛不住用户的高并发请求的时候.各个操作系统给出了自己对应的答案, 而linux给出的答案是epool.epool是 ...
- Linux认知之旅【05 进一步了解Linux装软件】!
一.Linux软件管理系统 二.Linux还可以用源码安装 三.Linux软件配置
- .NET Core Linux 部署实践
部署环境:CentOS 7 x64 必要条件:当前用户有sudo权限 1. 安装依赖包sudo yum install libunwind libicu2. 下载.net core安装文件curl - ...
- # ML学习小笔记—Where does the error come from?
关于本课程的相关资料http://speech.ee.ntu.edu.tw/~tlkagk/courses_ML17.html 错误来自哪里? error due to "bias" ...
- GDI+绘制可滚动的窗口
在winform中绘制图形,可以使用gdi+来完成. 当绘制的图形大于目前窗口大小时,就需要滚动条来帮忙显示. 设置属性:Form.AutoScrollMinSize为要显示内容的大小. privat ...
- select chosen 禁用下拉框某一个option
$("#tbParBudCode option[value='" + budCodeId + "']").attr("disabled", ...
- 【Luogu】P2154虔诚的墓主人(树状数组)
题目链接 这题就是考虑我们有这样一个情况