题目链接:http://poj.org/problem?id=1329

 #include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const double eps = 1e-;
int sgn(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
struct Point{
double x, y;
Point(){}
Point(double _x, double _y){
x = _x, y = _y;
}
bool operator == (Point b) const{
return sgn(x - b.x) == && sgn(y - b.y) == ;
}
bool operator < (Point b)const{
return sgn(x - b.x) == ? sgn(y - b.y < ) : x < b.x;
}
Point operator - (const Point &b)const{
return Point(x - b.x, y - b.y);
}
//叉积
double operator ^(const Point &b){
return x * b.y - y * b.x;
}
//点积
double operator *(const Point &b){
return x * b.x + y * b.y;
}
double len(){
return hypot(x, y);
}
double len2(){
return x * x + y * y;
}
double distant(Point p){
return hypot(x - p.x, y - p.y);
}
Point operator + (const Point &b)const{
return Point (x + b.x, y + b.y);
}
Point operator * (const double &k)const{
return Point(x * k, y * k);
}
Point operator / (const double &k)const{
return Point(x / k, y / k);
}
//逆时针旋转90度
Point rotleft(){
return Point(- y, x);
}
//顺时针旋转90度
Point rotright(){
return Point(y, -x);
}
};
struct Line{
Point s, e;
Line(){}
Line(Point _s, Point _e){s = _s, e = _e;}
Point crosspoint(Line v){
double a1 = (v.e - v.s)^(s - v.s);
double a2 = (v.e - v.s)^(e - v.s);
return Point((s.x*a2 - e.x*a1)/(a2 - a1),(s.y*a2 - e.y*a1)/(a2 - a1));
}
};
struct circle{
Point p;
double r;
circle(){}
circle(Point _p, double _r){
p = _p, r = _r;
}
circle(double x, double y, double _r){
p = Point(x, y);
r = _r;
}
//三角形外接圆
circle(Point a, Point b, Point c){
Line u = Line( (a + b) / ,((a + b) / ) + ((b - a).rotleft()) );
Line v = Line( (b + c) / ,((b + c) / ) + ((c - b).rotleft()) );
p = u.crosspoint(v);
r = p.distant(a);
}
};
void print(double num) {
if (sgn(num) < ) {
printf("- "); num = -num;
}
else printf("+ ");
printf("%.3f", num);
}
int main()
{
double x1, x2, x3, y1, y2, y3;
while(~scanf("%lf%lf%lf%lf%lf%lf",&x1, &y1, &x2, &y2, &x3, &y3))
{
circle a = circle(Point(x1, y1), Point(x2, y2), Point(x3, y3));
double c = a.r * a.r - (a.p.x * a.p.x + a.p.y * a.p.y);
if (sgn(a.p.x) == )printf("x^2");
else { printf("(x "); print(-a.p.x); printf(")^2"); }
printf(" + ");
if (sgn(a.p.y) == )printf("y^2");
else { printf("(y "); print(-a.p.y); printf(")^2"); }
printf(" = %.3f^2\n", a.r);
printf("x^2 + y^2 ");
print(-a.p.x * 2.0);
printf("x ");
print(-a.p.y * 2.0);
printf("y ");
print(-c);
printf(" = 0\n");
printf("\n");
}
return ;
}

POJ 1329 Circle Through Three Points(三角形外接圆)的更多相关文章

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

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

  2. POJ - 1329 Circle Through Three Points 求圆

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

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

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

  4. ●POJ 1329 Circle Through Three Points

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

  5. poj1329Circle Through Three Points(三角形外接圆)

    链接 套模板 不知道有没有x,y=0情况,不过这种情况都按+号输出的. #include <iostream> #include<cstdio> #include<cst ...

  6. POJ 1329 三角外接圆

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

  7. poj1329 Circle Through Three Points

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

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

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

  9. poj 1981 Circle and Points

    Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8131   Accepted: 2899 ...

随机推荐

  1. Java学习之抽象类

    抽象类特点: 1.抽象方法必须定义在抽象类中2.abstract关键字修饰:只能修饰类和方法3.抽象类不能实例化4.抽象类中的方法要被使用,必须由子类重写所有的抽象方法,实例化其子类 如果子类只重写部 ...

  2. java入门经验分享——记面向对象先导课程学习感想

    选择在暑期学习面向对象先导课程的初衷是为大二下学期面向对象课程做一些铺垫,接触入门java语言.在接触java的过程中,就编程语言的学习方法而言,我从刚入学时的手慌脚乱四处寻求帮助到现在慢慢养成了自己 ...

  3. nginx支持http2协议

    1.http2协议 HTTP 2.0 的主要目标是改进传输性能,实现低延迟和高吞吐量.从另一方面看,HTTP 的高层协议语义并不会因为这次版本升级而受影响.所有HTTP 首部.值,以及它们的使用场景都 ...

  4. vb写文件时报'Invalid procedure call or argument'

    原来的一段代码是这样的: Set fso3 = CreateObject("Scripting.FileSystemObject")                  'msgbo ...

  5. 快速调通支付宝当面付Demo

    1.访问如下地址: https://auth.alipay.com/login/ant_sso_index.htm?goto=https%3A%2F%2Fopenhome.alipay.com%2Fp ...

  6. dubbo接口未更新,清maven缓存问题

    有时候idea maven reimport 并未更新到最新的版本 此时可以到./m2去进行手动清楚缓存再更新 cd .m2/repository/cn/dface/biz/couponcenter ...

  7. TreeMap源码解析笔记

    常见的数据结构有数组.链表,还有一种结构也很常见,那就是树.前面介绍的集合类有基于数组的ArrayList,有基于链表的LinkedList,还有链表和数组结合的HashMap,今天介绍基于树的Tre ...

  8. rem适配布局(rem+less+媒体查询 和 rem+flexible.js)

    1. rem 基础 rem 是一个相对单位,类似于 em ,em 是父元素字体大小. em 是相对于父元素  的字体大小来说的 rem 是相对于 html 元素 字体大小来说的 rem 优点 就是可以 ...

  9. codeforces863F Almost Permutation 费用流

    题目传送门 题意: 构造出一个数列,数字在$1~n$的范围内,要求$\sum_{i=1}^n  count(i)^{2}$最小,$count(i)$的意思是数列中i出现的次数.并且数列要满足两种类型的 ...

  10. 重新创建redis集群的注意事项

    一.重新创建redis集群的注意事项 1.将每个节点下aof.rdb.nodes.conf本地备份文件删除: 2.127.0.0.1:7001> flushdb #清空当前数据库(这一步可以省略 ...