●POJ 1329 Circle Through Three Points
题链:
http://poj.org/problem?id=1329
题解:
计算几何,求过不共线的三点的圆
就是用向量暴力算出来的东西。。。
(设出外心M的坐标,由于$|\vec{MA}|=|\vec{MB}|=|\vec{MC}|$,可以解出M点坐标。)
代码:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const double eps=1e-8;
int sign(double x){
if(fabs(x)<=eps) return 0;
return x<0?-1:1;
}
void Pout(double x){//Print_Out
if(sign(x)<0) printf(" - ");
else printf(" + ");
printf("%.3lf",fabs(x));
}
struct Point{
double x,y;
Point(double _x=0,double _y=0):x(_x),y(_y){}
int Read(){return scanf("%lf%lf",&x,&y);}
};
typedef Point Vector;
Vector operator + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Point A,Point B){return Vector(A.x-B.x,A.y-B.y);}
double operator ^ (Vector A,Vector B){return A.x*B.y-A.y*B.x;}
double operator * (Vector A,Vector B){return A.x*B.x+A.y*B.y;}
struct Circle{
Point o; double r;
Circle(Point _o=Point(),double _r=0):o(_o),r(_r){}
void PrintSE(){//Print_Standard_Equation
printf("(x");Pout(-o.x);printf(")^2"); printf(" + ");
printf("(y");Pout(-o.y);printf(")^2"); printf(" = ");
printf("%.3lf^2\n",r);
}
void PrintNE(){//Print_Normal_Equation
printf("x^2 + y^2");
Pout(-2*o.x);printf("x");
Pout(-2*o.y);printf("y");
Pout(o.x*o.x+o.y*o.y-r*r);
printf(" = 0\n\n");
}
};
double GL(Vector A){//Get_Length
return sqrt(A*A);
}
Circle GC(Point P1,Point P2,Point P3){//Get_Circle
Vector B=P2-P1,C=P3-P1; Point P0;
P0.x=((B*B)*C.y-(C*C)*B.y)/(2*(B^C))+P1.x;
P0.y=((B*B)*C.x-(C*C)*B.x)/(2*(C^B))+P1.y;
return Circle(P0,GL(P0-P1));
}
int main(){
Point A,B,C;
while(~A.Read()&&~B.Read()&&~C.Read()){
GC(A,B,C).PrintSE();
GC(A,B,C).PrintNE();
}
return 0;
}
●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 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...
- 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> # ...
- 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 1329(已知三点求外接圆方程.)
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3766 Acce ...
- poj 1981 Circle and Points
Circle and Points Time Limit: 5000MS Memory Limit: 30000K Total Submissions: 8131 Accepted: 2899 ...
- POJ 1981 Circle and Points (扫描线)
[题目链接] http://poj.org/problem?id=1981 [题目大意] 给出平面上一些点,问一个半径为1的圆最多可以覆盖几个点 [题解] 我们对于每个点画半径为1的圆,那么在两圆交弧 ...
随机推荐
- 201621123040《Java程序设计》第十一周学习总结
1.本周学习总结 1.1以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 2.书面作业 2.1源代码阅读:多线程程序BounceThread 2.1.1BallRunnable类有什么用?为什 ...
- 项目Alpha冲刺Day11
一.会议照片 二.项目进展 1.今日安排 熟悉框架的使用以及编写用户查看的界面以及该页面内的操作. 2.问题困难 全局的日期转换出现问题,在序列化的时候是按照配置来的,但是反序列化的时候就错了,问题待 ...
- 雷云Razer Synapse2.0使用测评 -第二次作业
雷蛇云驱动Razer Synapse2.0使用测评 雷蛇(Razer)是全球顶级游戏设备品牌之一,1998年由CEO Min-Liang Tan和Robert "Razerguy" ...
- 如何使用ILAsm与ILDasm修改.Net exe(dll)文件
一.背景 最近项目组新上项目,交付的时间比较急迫,原本好的分支管理习惯没有遵守好,于是出现下面状况: 多个小伙伴在不同的分支上开发. 原本QA环境也存在一个阻碍性的bug A 一位同事在QA环境发布了 ...
- NOIP2017 列队
https://www.luogu.org/problemnew/show/P3960 p<=500 50分 模拟 每个人的出队只会影响当前行和最后一列 p<=500,有用的行只有500行 ...
- hp MSA50 5盘RAID5重建为4盘RAID5怎么恢复数据
[用户单位] XX省电视台[数据恢复故障描述] 一台HP 服务器,挂接一台HP MSA50磁盘阵列,内接5块1TB硬盘,原先结构为RAID5. 使用一段时间后,其中一块硬盘掉线,因RAID5支持一块硬 ...
- Python内置函数(55)——globals
英文文档: globals() Return a dictionary representing the current global symbol table. This is always the ...
- setInterval()使用时易疏忽的点
举个例子: 一道题目 这两个程序的区别就在于我向setInterval的参数一function写入了参数.这就是导致运行结果不尽如人意的原因. setInterval()方法可以接收三个参数,此参数会 ...
- Celery 分布式任务队列快速入门
Celery 分布式任务队列快速入门 本节内容 Celery介绍和基本使用 在项目中如何使用celery 启用多个workers Celery 定时任务 与django结合 通过django配置cel ...
- ECSHOP模板 蘑菇街2018广告楼层设置说明
楼层广告以及说明 图1 ------------------ 设置,通过,后台,模板设置,分类下的商品,选用需要显示的商品分类 图2------------------ 后台,编辑商品分类的广告链接. ...