博客
关于我
2020牛客暑期多校第二场 B - Boundary(简单计算几何)
阅读量:316 次
发布时间:2019-03-04

本文共 1885 字,大约阅读时间需要 6 分钟。


题解这样说:

在这里插入图片描述
但是我这样写了却过不了,可能是计算角度时浮点数的误差太大了,实际上主流的做法并不是从圆心角下手,而是根据三点共圆,因为必过原点,那么只需枚举另外的两个点,计算出圆心坐标,然后使用 m a p map map统计每次枚举有多少相同的圆心坐标

关于三点共圆求圆心,可以参考

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define fi first#define se second#define Vector Point#define pb push_back#define ins insert#define lowbit(x) (x&(-x))#define mkp(x,y) make_pair(x,y)#define mem(a,x) memset(a,x,sizeof a);typedef long long ll;typedef long double ld;typedef unsigned long long ull;typedef pair
P;typedef pair
pdd;const double eps=1e-8;const double pi=acos(-1.0);const int inf=0x3f3f3f3f;const ll INF=1e18;const int Mod=1e9+7;const int maxn=2e5+10;inline int dcmp(double d){ if(fabs(d)
0?1:-1;}inline int cmp(double x,double y){ return dcmp(x-y);}struct Point{ double x,y; Point(double a=0,double b=0):x(a),y(b){ } Vector operator + (Vector B){ return Vector(x+B.x,y+B.y); } Vector operator - (Point B){ return Vector(x-B.x,y-B.y); } Vector operator * (double d){ //数乘 return Vector(x*d,y*d); } double operator * (Vector B){ //数量积 return x*B.x+y*B.y; } Vector operator / (double d){ return Vector(x/d,y/d); } double operator ^ (Vector B){ //叉乘 return x*B.y-y*B.x; } bool operator < (const Point &b) const { if(dcmp(x-b.x)==0) return y
mp;pdd getCircleCenter(Point a,Point b,Point c){ double x=((a.x*a.x+a.y*a.y)*(b.y-c.y)+(b.x*b.x+b.y*b.y)*(c.y-a.y)+(c.x*c.x+c.y*c.y)*(a.y-b.y)) / (2.0*(a.x*(b.y-c.y)-a.y*(b.x-c.x)+b.x*c.y-c.x*b.y)); double y=((a.x*a.x+a.y*a.y)*(c.x-b.x)+(b.x*b.x+b.y*b.y)*(a.x-c.x)+(c.x*c.x+c.y*c.y)*(b.x-a.x)) / (2.0*(a.x*(b.y-c.y)-a.y*(b.x-c.x)+b.x*c.y-c.x*b.y)); return make_pair(x,y);}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); //ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int n; scanf("%d",&n); for(int i=0;i

转载地址:http://ybqq.baihongyu.com/

你可能感兴趣的文章
MySQL in 太多过慢的 3 种解决方案
查看>>
MySQL InnoDB 三大文件日志,看完秒懂
查看>>
Mysql InnoDB 数据更新导致锁表
查看>>
Mysql Innodb 锁机制
查看>>
MySQL InnoDB中意向锁的作用及原理探
查看>>
MySQL InnoDB事务隔离级别与锁机制深入解析
查看>>
Mysql InnoDB存储引擎 —— 数据页
查看>>
Mysql InnoDB存储引擎中的checkpoint技术
查看>>
Mysql InnoDB存储引擎中缓冲池Buffer Pool、Redo Log、Bin Log、Undo Log、Channge Buffer
查看>>
MySQL InnoDB引擎的锁机制详解
查看>>
Mysql INNODB引擎行锁的3种算法 Record Lock Next-Key Lock Grap Lock
查看>>
mysql InnoDB数据存储引擎 的B+树索引原理
查看>>
mysql innodb通过使用mvcc来实现可重复读
查看>>
mysql insert update 同时执行_MySQL进阶三板斧(三)看清“触发器 (Trigger)”的真实面目...
查看>>
mysql interval显示条件值_MySQL INTERVAL关键字可以使用哪些不同的单位值?
查看>>
Mysql join原理
查看>>
MySQL Join算法与调优白皮书(二)
查看>>
Mysql order by与limit混用陷阱
查看>>
Mysql order by与limit混用陷阱
查看>>
mysql order by多个字段排序
查看>>