poj 1329 Circle Through Three Points(求圆心+输出)
题目链接:http://poj.org/problem?id=1329
输出很蛋疼,要考虑系数为0,输出也不同
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
const double INF = 1000000000000000.000; struct Point
{
double x,y;
Point(double x=, double y=) : x(x),y(y) { } //构造函数
};
typedef Point Vector; struct Circle
{
Point c;
double r;
Circle() {}
Circle(Point c,double r): c(c),r(r) {}
};
Vector operator + (Vector A , Vector B)
{
return Vector(A.x+B.x,A.y+B.y);
}
Vector operator - (Vector A , Vector B)
{
return Vector(A.x-B.x,A.y-B.y);
}
Vector operator * (Vector A, double p)
{
return Vector(A.x*p,A.y*p);
}
Vector operator / (Vector A , double p)
{
return Vector(A.x/p,A.y/p);
} bool operator < (const Point& a,const Point& b)
{
return a.x < b.x ||( a.x == b.x && a.y < b.y);
} int dcmp(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b)
{
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} ///向量(x,y)的极角用atan2(y,x);
inline double Dot(Vector A, Vector B)
{
return A.x*B.x + A.y*B.y;
}
inline double Length(Vector A)
{
return sqrt(Dot(A,A));
}
inline double Angle(Vector A, Vector B)
{
return acos(Dot(A,B) / Length(A) / Length(B));
}
double Cross(Vector A, Vector B)
{
return A.x*B.y - A.y * B.x;
}
Vector vecunit(Vector v)
{
return v / Length(v); //单位向量
} Point read_point()
{
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
}
Vector Normal(Vector A)
{
double L = Length(A);
return Vector(-A.y/L, A.x/L);
}
Point GetLineIntersecion(Point P, Vector v,Point Q,Vector w)
{
Vector u = P - Q;
double t = Cross(w,u)/Cross(v,w);
return P + v*t;
} //多边形
//求面积
double PolygonArea(Point* p,int n) //n个点
{
double area = ;
for(int i=; i<n-; i++)
{
area += Cross(p[i]-p[],p[i+]-p[]);
}
return area/;
} /*************************************分 割 线*****************************************/ int main()
{
//freopen("E:\\acm\\input.txt","r",stdin); Point A,B,C,O;
double R;
while(scanf("%lf %lf %lf %lf %lf %lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y) == )
{ Point mid1 = (A+B)/;
Point mid2 = (B+C)/;
Vector v1 = Normal(A-B);
Vector v2 = Normal(B-C); O = GetLineIntersecion(mid1,v1,mid2,v2);
R = Length(O-A); if(dcmp(O.x)>) printf("(x - %.3f)^2 + ",O.x);
else if(dcmp(O.x) == ) printf("x^2 + ",O.x);
else printf("(x + %.3f)^2 + ",-O.x);
if(dcmp(O.y)>) printf("(y - %.3f)^2 = ",O.y);
else if(dcmp(O.y) == ) printf("y^2 = ",O.y);
else printf("(y + %.3f)^2 = ",-O.y);
printf("%.3f^2\n",R); if(dcmp(O.x)>) printf("x^2 + y^2 - %.3fx ",*O.x);
else if(dcmp(O.x) == ) printf("x^2 + y^2 ");
else printf("x^2 + y^2 + %.3fx ",-*O.x); if(dcmp(O.y)>) printf("- %.3fy ",*O.y);
else if(dcmp(O.y) < ) printf("+ %.3fy ",-*O.y); if(dcmp(O.x*O.x+O.y*O.y-R*R) > )
printf("+ %.3f = 0\n",O.x*O.x+O.y*O.y-R*R);
else if(dcmp(O.x*O.x+O.y*O.y-R*R) == )
printf("= 0\n");
else
printf("- %.3f = 0\n",-O.x*O.x-O.y*O.y+R*R);
printf("\n");
}
}
poj 1329 Circle Through Three Points(求圆心+输出)的更多相关文章
- POJ - 1329 Circle Through Three Points 求圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4112 Acce ...
- ●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: ...
- POJ 1329
三角外接圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3169 Acce ...
- POJ 3259 Wormholes(最短路径,求负环)
POJ 3259 Wormholes(最短路径,求负环) Description While exploring his many farms, Farmer John has discovered ...
随机推荐
- C# 执行批处理文件(*.bat)的方法代码
代码如下: static void Main(string[] args){ Process proc = null; try { st ...
- MVC5学习笔记
买了一本MVC5的书:ASP.NET MVC 5 高级编程(第5版).边学边记录一下 1.快速创建模型类,如:自动实现的属性 {get;set;} 输入“prop",按Tab两次,默认属性值 ...
- JavaScript Invalid Date Verify
if ( Object.prototype.toString.call(d) === "[object Date]" ) { // it is a date if ( isNaN( ...
- angular2 组件之间通讯-使用服务通讯模式 2016.10.27 基于正式版ng2
工作中用到ng2的组件通讯 奈何官方文档言简意赅 没说明白 自己搞明白后 整理后分享下 rxjs 不懂的看这篇文章 讲很详细 http://www.open-open.com/lib/view/ope ...
- 设计模式之 State 状态模式
状态模式的核心在于 1. 状态的转换导致行为(Handle)的差异,比如人的状态是饿的时候,吃(Handle)的行为是2个馒头,人状态是不太饿的时候,吃(Handle)的行为是半个馒头 2. Stat ...
- div section article aside的理解
div 是一个大的容器 内部可以包含header main nav aside footer等标签 没有语义,多用于为脚本添加样式 section的语义比div语义强些,用于主题性比较强的内容,比如一 ...
- js 中的流程控制-循环(for)语句
for语句: <script> /* for(exp1;exp2;exp3){ 循环体; } exp1:无条件的执行第一个表达式 exp2:判断是否能执行循环体的条伯 exp3:做增量的操 ...
- Activity的"singleTask"之谜
官方文档称 以这种方式启动的Activity总是属于一个任务的根Activity.果真如此吗?本文将为你解开Activity的"singleTask"之谜. 任务(Task)是个什 ...
- 使用python实现HMM
一直想用隐马可夫模型做图像识别,但是python的scikit-learn组件包的hmm module已经不再支持了,需要安装hmmlearn的组件,不过hmmlearn的多项式hmm每次出来的结果都 ...
- JS面向对象思想(OOP)
直接看js好了,模拟创建一个奥运会 function 奥运会Class(主题) { // 删除主题 // delete this.主题; this.主题 = 主题; this.开幕时间; this.闭 ...