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 ...
随机推荐
- CollectionView就是这么简单!
UICollectionView 和 UICollectionViewController 类是iOS6 新引进的API,用于展示集合视图,布局更加灵活,可实现多列布局,用法类似于UITableVie ...
- ios 字符串替换方法
string=[string stringByReplacingOccurrencesOfString:@"-"withString:@"/"];
- 217. Contains Duplicate(C++)
217. Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your ...
- [Lua]基于cc.load('mvc') .ViewBase索引资源方案
local MainScene = class("MainScene", cc.load("mvc").ViewBase) MainScene.RESOURCE ...
- C++静态成员函数访问非静态成员的几种方法
大家都知道C++中类的成员函数默认都提供了this指针,在非静态成员函数中当你调用函数的时候,编译器都会“自动”帮你把这个this指针加到函数形参里去.当然在C++灵活性下面,类还具备了静态成员和静态 ...
- curl批处理从官方demo封装
官方demo // 创建一对cURL资源 $ch1 = curl_init(); $ch2 = curl_init(); // 设置URL和相应的选项 curl_setopt($ch1, CURLOP ...
- php基础知识【函数】(1)数组array
一.排序 1.sort -- 从最低到最高排序,删除原有的键名,赋予新的键名[字母比数字高] 2.rsort -- 逆向排序(最高到最低),删除原有的键名,赋予新的键名[字母比数字高] 3.asort ...
- Shortcut Collapse project or projects in the Solution Explorer Microsoft Visual Studio 2008
The standard windows keyboard shortcuts for expanding and collapsing treeviews are: Numeric Keypad * ...
- iOS: 学习笔记, 值与引用类型(译自: https://developer.apple.com/swift/blog/ Aug 15, 2014 Value and Reference Types)
值和引用类型 Value and Reference Types 在Swift中,有两种数据类型. 一是"值类型"(value type), 它是每一个实例都保存有各自的数据,通常 ...
- sublime支持显示中文
Sublime Text 2是一个非常不错的源代码及文本编辑器,但是不支持GB2312和GBK编码在很多情况下会非常麻烦.不过Sublime Package Control所以供的插件可以让Subli ...