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

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<algorithm>
  4. #include<iostream>
  5. #include<cstring>
  6. using namespace std;
  7. typedef long long ll;
  8. const double eps = 1e-;
  9. int sgn(double x)
  10. {
  11. if(fabs(x) < eps) return ;
  12. else return x < ? - : ;
  13. }
  14. struct Point{
  15. double x, y;
  16. Point(){}
  17. Point(double _x, double _y){
  18. x = _x, y = _y;
  19. }
  20. bool operator == (Point b) const{
  21. return sgn(x - b.x) == && sgn(y - b.y) == ;
  22. }
  23. bool operator < (Point b)const{
  24. return sgn(x - b.x) == ? sgn(y - b.y < ) : x < b.x;
  25. }
  26. Point operator - (const Point &b)const{
  27. return Point(x - b.x, y - b.y);
  28. }
  29. //叉积
  30. double operator ^(const Point &b){
  31. return x * b.y - y * b.x;
  32. }
  33. //点积
  34. double operator *(const Point &b){
  35. return x * b.x + y * b.y;
  36. }
  37. double len(){
  38. return hypot(x, y);
  39. }
  40. double len2(){
  41. return x * x + y * y;
  42. }
  43. double distant(Point p){
  44. return hypot(x - p.x, y - p.y);
  45. }
  46. Point operator + (const Point &b)const{
  47. return Point (x + b.x, y + b.y);
  48. }
  49. Point operator * (const double &k)const{
  50. return Point(x * k, y * k);
  51. }
  52. Point operator / (const double &k)const{
  53. return Point(x / k, y / k);
  54. }
  55. //逆时针旋转90度
  56. Point rotleft(){
  57. return Point(- y, x);
  58. }
  59. //顺时针旋转90度
  60. Point rotright(){
  61. return Point(y, -x);
  62. }
  63. };
  64. struct Line{
  65. Point s, e;
  66. Line(){}
  67. Line(Point _s, Point _e){s = _s, e = _e;}
  68. Point crosspoint(Line v){
  69. double a1 = (v.e - v.s)^(s - v.s);
  70. double a2 = (v.e - v.s)^(e - v.s);
  71. return Point((s.x*a2 - e.x*a1)/(a2 - a1),(s.y*a2 - e.y*a1)/(a2 - a1));
  72. }
  73. };
  74. struct circle{
  75. Point p;
  76. double r;
  77. circle(){}
  78. circle(Point _p, double _r){
  79. p = _p, r = _r;
  80. }
  81. circle(double x, double y, double _r){
  82. p = Point(x, y);
  83. r = _r;
  84. }
  85. //三角形外接圆
  86. circle(Point a, Point b, Point c){
  87. Line u = Line( (a + b) / ,((a + b) / ) + ((b - a).rotleft()) );
  88. Line v = Line( (b + c) / ,((b + c) / ) + ((c - b).rotleft()) );
  89. p = u.crosspoint(v);
  90. r = p.distant(a);
  91. }
  92. };
  93. void print(double num) {
  94. if (sgn(num) < ) {
  95. printf("- "); num = -num;
  96. }
  97. else printf("+ ");
  98. printf("%.3f", num);
  99. }
  100. int main()
  101. {
  102. double x1, x2, x3, y1, y2, y3;
  103. while(~scanf("%lf%lf%lf%lf%lf%lf",&x1, &y1, &x2, &y2, &x3, &y3))
  104. {
  105. circle a = circle(Point(x1, y1), Point(x2, y2), Point(x3, y3));
  106. double c = a.r * a.r - (a.p.x * a.p.x + a.p.y * a.p.y);
  107. if (sgn(a.p.x) == )printf("x^2");
  108. else { printf("(x "); print(-a.p.x); printf(")^2"); }
  109. printf(" + ");
  110. if (sgn(a.p.y) == )printf("y^2");
  111. else { printf("(y "); print(-a.p.y); printf(")^2"); }
  112. printf(" = %.3f^2\n", a.r);
  113. printf("x^2 + y^2 ");
  114. print(-a.p.x * 2.0);
  115. printf("x ");
  116. print(-a.p.y * 2.0);
  117. printf("y ");
  118. print(-c);
  119. printf(" = 0\n");
  120. printf("\n");
  121. }
  122. return ;
  123. }

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. RTTI RAII

    RTTI(Run Time Type Identification)即通过运行时类型识别,程序能够使用基类的指针或引用来检查着这些指针或引用所指的对象的实际派生类型. RTTI提供了以下两个非常有用的 ...

  2. Django框架(二十)—— Django rest_framework-认证组件

    目录 Django rest_framework-认证组件 一.什么是认证 二.利用token记录认证过的用户 1.什么是token 2.token的原理 3.cookie.session.token ...

  3. js基本函数和基本方法

    日期时间函数(需要用变量调用): var b = new Date(); //获取当前时间 b.getTime() //获取时间戳 b.getFullYear() //获取年份 b.getMonth( ...

  4. 通过一条很慢的SQL梳理下SQL优化基础

  5. sql 查询库是否存在

    网上查了很多,但是都是不完整的,很多坑,后面终于摸索出来了:DROP DATABASE IF EXISTS 库名(不要加引号); 这句话的意思就是如果库存在,就删除库,然后再新建库就行了.

  6. 逻辑回归原理,推导,sklearn应用

    目录 逻辑回归原理,推导,及sklearn中的使用 1 从线性回归过渡到逻辑回归 2 逻辑回归的损失函数 2.1 逻辑回归损失函数的推导 2.2 梯度下降法 2.3 正则化 3 用逻辑回归进行多分类 ...

  7. 如何在有scoped不影响elementUI 的其他页面组件,进行单页面修改的几种方法。

    方式一:内联式css 内联式css , 优点:修改其他方便.缺点:造成页面臃肿,不利于后期维护. 方式二:外链css 外链css ,优点:对其他文件无影响,但会造成多个文件css  (缺点) @imp ...

  8. multipart/form-data,application/json和application/x-www-form-urlencoded区别

    application/json和application/x-www-form-urlencoded都是表单数据发送时的编码类型. EncType: enctype 属性规定在发送到服务器之前应该如何 ...

  9. Lock中使用Condition实现等待通知

    Condition类有很好的灵活性,可以实现多路通知功能,一个Lock对象中可以创建多个Condition对象实例,线程对象可以注册在指定的Condition中,进而有选择的进行线程通知,在调度线程上 ...

  10. 2018-8-10-win10-uwp-DataContext-

    title author date CreateTime categories win10 uwp DataContext lindexi 2018-08-10 19:16:53 +0800 2018 ...