POJ - 1329 Circle Through Three Points 求圆
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 4112 | Accepted: 1712 |
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
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 求圆的更多相关文章
- poj 1329 Circle Through Three Points(求圆心+输出)
题目链接:http://poj.org/problem?id=1329 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...
- ●POJ 1329 Circle Through Three Points
题链: http://poj.org/problem?id=1329 题解: 计算几何,求过不共线的三点的圆 就是用向量暴力算出来的东西... (设出外心M的坐标,由于$|\vec{MA}|=|\ve ...
- POJ 1329 Circle Through Three Points(三角形外接圆)
题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...
- POJ 1329 Circle Through Three Points(三角形外心)
题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...
- poj 1329(已知三点求外接圆方程.)
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3766 Acce ...
- 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 ...
- poj1329 Circle Through Three Points
地址:http://poj.org/problem?id=1329 题目: Circle Through Three Points Time Limit: 1000MS Memory Limit: ...
- JAVA求圆的面积
import java.text.DecimalFormat;import java.util.Scanner; public class TheAreaOfCircle { public stati ...
- POJ 1329
三角外接圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3169 Acce ...
随机推荐
- 2016.6.19——C++杂记
C++杂记 补充的小知识点: 1.while(n--)和while(--n)区别: while(n--)即使不满足也执行一次循环后跳出. while(--n)不满足直接跳出循环,不执行语句. 用cou ...
- 【技巧总结】Penetration Test Engineer[5]-Operating System Security(SQL Server、MySQL提权)
4.数据库安全基础 4.1.MSSQL 数据库角色权限 sysadmin:执行SQL Server中的任何动作 db_owner:可以执行数据库中技术所有动作的用户 public:数据库的每个合法用户 ...
- 如何更方便的查看Linux内核代码的更新记录【转】
转自:http://blog.csdn.net/lee244868149/article/details/44302819 Linux内核的更新非常的快,如何快速的了解这些更新呢?最一般的办法就是把新 ...
- 【驱动】USB驱动·入门【转】
转自:http://www.cnblogs.com/lcw/p/3159371.html Preface USB是目前最流行的系统总线之一.随着计算机周围硬件的不断扩展,各种设备使用不同的总线接口,导 ...
- avalonJS-源码阅读(二)
上一篇文章讲述的avalon刷页面所用到的几个函数.这篇则是主要讲avalon对刷DOM刷出来的avalon自定义属性如何处理的. 目录[-] avalon页面处理(2) 数据结构 解析avalon标 ...
- 【bzoj3065】: 带插入区间K小值 详解——替罪羊套函数式线段树
不得不说,做过最爽的树套树———— 由于有了区间操作,我们很容易把区间看成一棵平衡树,对他进行插入,那么外面一层就是平衡树了,这就与我们之前所见到的不同了.我们之前所见到的大多数是线段树套平衡树而此题 ...
- 监听 手机back键和顶部的回退
// 回退事件,监听 手机back键和顶部的回退 pushHistory(); window.addEventListener("popstate", function(e) { ...
- FM的推导原理--推荐系统
FM:解决稀疏数据下的特征组合问题 Factorization Machine(因子分解机) 美团技术团队的文章,觉得写得很好啊:https://tech.meituan.com/deep-unde ...
- 无需编译app切换线上、测试环境
在咱们测试过程中,经常需要切换测试环境和线上环境.大致有如下几个方案. 一.服务器地址编译到app中 此种方式需要在代码里保存两套配置,一套指向线上,一套指向测试.通过编译参数分别生成测试包.线上包. ...
- thinkphp调试
Sql调试