题目链接: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. JSHOP2

    JSHOP2是一个HTN(hierarchy task network)规划器,是SHOP2(simple hierarchy ordered planner )的java实现版本. SHOP2的官网 ...

  2. jpql简单l查询

    JPQL全称Java Persistence Query Language package com.ytkj.entity; import javax.persistence.*; import ja ...

  3. python 根据字典的键值进行排序

    1.利用key排序 d = {'d1':2, 'd2':4, 'd4':1,'d3':3,} for k in sorted(d): print(k,d[k]) d1 2d2 4d3 3d4 1 2. ...

  4. grafana初体验

    1.centos版下载安装 wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.0.4-1.x86_6 ...

  5. Python 常见报错类型

    一.TypeError:类型错误,对象用来表示值的类型非预期类型时发生的错误 错误例子: age=18 print(‘我的年龄是’+age) 报错信息:TypeError: can only conc ...

  6. HashMap源码解析笔记

    首先简单介绍下HashMap: 1.HashMap有三种数据结构:数组,链表,红黑树. 2.HashMap是非线程安全的 3.HashMap存储的内容是键值对(key-value)映射,key.val ...

  7. React的性能优化 - 代码拆分之lazy的使用方法

    我们在某些网站上肯定看到过这样一种现象,页面上图片只有你滚动到那个位置附近的时候才会加载,否则就只占了个位,这就是延迟加载最普遍的应用场景. 我们react框架进行开发的时候也是一样,没有使用的组件是 ...

  8. 2019-9-2-C#委托

    title author date CreateTime categories C#委托 lindexi 2019-09-02 12:57:37 +0800 2018-2-13 17:23:3 +08 ...

  9. k8s容器-节点部署篇

    一. k8s节点部署 1. 环境规划 系统环境概述 系统环境说明 操作系统 Ubuntu16.04 or CentOS7 选的是CentOS7        -        Kubernetes版本 ...

  10. LSI 9271阵列卡开启JBOD!

    1.开机等待读取到RAID卡后按ctrl+y(进入阵列卡命令符界面) 2.输入AdpSetProp EnableJBOD 1 -a0(开启JBOD功能) AdpSetProp EnableJBOD 0 ...