Gym-101915B Ali and Wi-Fi 计算几何 求两圆交点
题意:给你n个圆,每个圆有一个权值,你可以选择一个点,可以获得覆盖这个点的圆中,权值最大的m个的权值,问最多权值是多少
题解:好像是叙利亚的题....我们画画图就知道,我们要找的就是圆与圆交的那部分里面的点,我们再仔细看看,
2个圆的交点一定在啊!
别急啊,两个圆包含了,都是交点,取哪呢?当然小圆圆心就够了啊(圆又不多,写的时候直接把所有的圆心都丢进去了)
然后枚举判断每个点有没有被在m个圆中就行了,这里维护最大的m个,用个堆就好了
- #include<bits/stdc++.h>
- using namespace std;
- typedef long double ld;
- const ld eps = 1e-;
- int dcmp(ld x)
- {
- if(fabs(x) < eps) return ;
- return x < ? - : ;
- }
- ld sqr(ld x) { return x * x; }
- struct Point
- {
- ld x, y;
- Point(ld x = , ld y = ):x(x), y(y) {}
- };
- Point operator - (const Point& A, const Point& B)
- {
- return Point(A.x - B.x, A.y - B.y);
- }
- bool operator == (const Point& A, const Point& B)
- {
- return dcmp(A.x - B.x) == && dcmp(A.y - B.x) == ;
- }
- ld Dot(const Point& A, const Point& B)
- {
- return A.x * B.x + A.y * B.y;
- }
- ld dis(Point a,Point b)
- {
- return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
- }
- ld Length(const Point& A) { return sqrt(Dot(A, A)); }
- ld angle(Point v) { return atan2(v.y, v.x); }
- struct Circle
- {
- Point c;
- ld r,v;
- Circle() {}
- Circle(Point c, ld r):c(c), r(r) {}
- inline Point point(double a)
- {
- return Point(c.x+cos(a)*r, c.y+sin(a)*r);
- }
- }a[];
- int getCircleCircleIntersection(Circle C1, Circle C2,Point &t1,Point &t2)
- {
- ld d = Length(C1.c - C2.c);
- if(dcmp(d) == )
- {
- if(dcmp(C1.r - C2.r) == ) return -;
- return ;
- }
- if(dcmp(C1.r + C2.r - d) < ) return ;
- if(dcmp(fabs(C1.r-C2.r) - d) > ) return ;
- ld a = angle(C2.c - C1.c);
- ld da = acos((C1.r*C1.r + d*d - C2.r*C2.r) / (*C1.r*d));
- Point p1 = C1.point(a-da), p2 = C1.point(a+da);
- t1=p1;
- if(p1 == p2) return ;
- t2=p2;
- return ;
- }
- Point jd[];
- ld ans,sum;
- int n,m,T,tot;
- priority_queue<int,vector<int>,greater<int> >q;
- int main()
- {
- scanf("%d",&T);
- while (T--)
- {
- tot=;
- ans=;
- scanf("%d%d",&n,&m);
- for (int i=;i<=n;i++) scanf("%Lf%Lf%Lf%Lf",&a[i].c.x,&a[i].c.y,&a[i].r,&a[i].v);
- for (int i=;i<=n;i++)
- for (int j=i+;j<=n;j++)
- {
- Point t1,t2;
- int why=getCircleCircleIntersection(a[i],a[j],t1,t2);
- if (why==)
- {
- tot++;
- jd[tot]=t1;
- }else
- if (why==)
- {
- tot++;jd[tot]=t1;
- tot++;jd[tot]=t2;
- }
- }
- for (int i=;i<=n;i++)
- {
- tot++;
- jd[tot]=a[i].c;
- }
- for (int i=;i<=tot;i++)
- {
- for (int j=;j<=n;j++)
- if (dcmp(dis(jd[i],a[j].c)-a[j].r)<=)
- {
- q.push(a[j].v);
- if ((int)q.size()>m) q.pop();
- }
- sum=;
- while (!q.empty()) sum+=q.top(),q.pop();
- ans=max(ans,sum);
- }
- printf("%.Lf\n",ans);
- }
- }
Gym-101915B Ali and Wi-Fi 计算几何 求两圆交点的更多相关文章
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...
- ZOJ 1280 Interesting Lines | 求两直线交点
原题: 求两直线交点 思路借鉴于:http://blog.csdn.net/zxy_snow/article/details/6341282 感谢大佬 #include<cstdio> # ...
- hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)
Mirror and Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu5858 Hard problem(求两圆相交面积)
题目传送门 Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- 求两圆相交部分面积(C++)
已知两圆圆心坐标和半径,求相交部分面积: #include <iostream> using namespace std; #include<cmath> #include&l ...
- UVa 10674 (求两圆公切线) Tangents
题意: 给出两个圆的圆心坐标和半径,求这两个圆的公切线切点的坐标及对应线段长度.若两圆重合,有无数条公切线则输出-1. 输出是按照一定顺序输出的. 分析: 首先情况比较多,要一一判断,不要漏掉. 如果 ...
- Gym-101158J Cover the Polygon with Your Disk 计算几何 求动圆与多边形最大面积交
题面 题意:给出小于10个点形成的凸多边形 和一个半径为r 可以移动的圆 求圆心在何处的面积交最大,面积为多少 题解:三分套三分求出圆心位置,再用圆与多边形面积求交 #include<bits/ ...
- hdu 5120 (求两圆相交的面积
题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...
- [poj] 1269 [zoj] 1280 Interesting Lines || 求两直线交点
POJ原题 ZOJ原题 多组数据.每次给出四个点,前两个点确定一条直线,后两个点确定一条直线,若平行则输出"NONE",重合输出"LINE",相交输出" ...
随机推荐
- 后端springmvc,前端html5的FormData实现文件断点上传
前言 最近项目中有使用到文件断点上传,得空便总结总结,顺便记录一下,毕竟“好记性不如烂笔头”. 后端代码: package com.test.controller; import java.io.Bu ...
- 努比亚 Z17s (Nubia NX595J) 解锁BootLoader 并刷入recovery ROOT
首先下载好工具链接:https://pan.baidu.com/s/1nw7BoZB 密码:zuun 备用下载链接:https://pan.baidu.com/s/1c3mUQGg 本篇教程教你如何傻 ...
- 【Linux】七种运行级别
运行级别:即系统的运行模式. 级别类型: 0:关机状态. 1:单用户模式. 2:字符界面的多用户模式(不支持网络). 3:字符界面的多用户模式(运行最完整的模式). 4:未分配使用,系统保留. 5:图 ...
- C#使用各种时间戳及转换
/// <summary> /// DateTime时间格式转换为13位带毫秒的Unix时间戳 /// </summary> /// <param name=" ...
- HDU_1850_nim游戏
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32 ...
- monad - the Category hierachy
reading the "The Typeclassopedia" by Brent Yorgey in Monad.Reader#13 ,and found that " ...
- 关于MySQL,Oracle和SQLServer的特点以及之间区别
关系型数据库:是指采用了关系模型来组织数据的数据库.简单来说,关系模型指的就是二维表格模型,而一个关系型数据库就是由二维表及其之间的联系组成的一个数据组织. 非关系型数据库:非关系型数据库严格上说不是 ...
- 使用.Net Core RT 标准动态库
这个文档可以引导你如何通过CoreRT生成一个原生标准的系统动态库让其他编程语言调用. CoreRT 可以构建静态库, 这些库可以在编译时链接或者也可以构建运行时所需的共享库, 创建一个支持CoreR ...
- S-HR界面控件赋值取值
属性值: this.getField("entrys.variationReason").shrPromptBox("getValue").name
- [luogu1129 ZJOI2007] 矩阵游戏 (二分图最大匹配)
传送门 Description Input Output Sample Input 2 2 0 0 0 1 3 0 0 1 0 1 0 1 0 0 Sample Output No Yes HINT ...