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",相交输出" ...
随机推荐
- 利用set特性判断list是否存在重复的值
List<String> list2=new ArrayList();//存放很多值的list //根据set不能存储相同的值该特性来判断list2中的值是否重复 HashSet set ...
- C#程序集版本控制文件属性祥解
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices ...
- Table边框使用总结 ,只显示你要显示的边框
表格的常用属性 基本属性有:width(宽度).height(高度).border(边框值).cellspacing(表格的内宽,即表格与tr之间的间隔). cellpadding(表格内元素的间隔, ...
- windows 下安装mysql 成功版
mysql 下载地址 http://dev.mysql.com/downloads/ zip版下载 解压到本地 假设文件保存在C:\mysql-5.7.17-winx64 1.以管理员身份运行cmd. ...
- js判断数组中是否包含某个值
/** * 判断数组中是否包含某个值 * @param arr 数组 * @param str 值 * @returns {boolean} */ function contains(arr, str ...
- vue使用插槽分发内容slot的用法
将父组件的内容放到子组件指定的位置叫做内容分发 //在父组件里使用子组件 <son-tmp> <div>我是文字,我需要放到son-tmp组件里面制定的位置</div&g ...
- vue.js的ajax和jsonp请求
首先要声明使用ajax 在 router下边的 Index.js中 import VueResource from 'vue-resource'; Vue.use(VueResource); ajax ...
- angular搭建
脚手架工具:angular-cli 1. npm install -g @angular/cli 2.ng new xxx 3.cd xxx , ng serve
- Java中StringTokenizer类的使用
StringTokenizer是一个用来分隔String的应用类,相当于VB的split函数. 1.构造函数 public StringTokenizer(String str) public Str ...
- python jieba分词(添加停用词,用户字典 取词频
中文分词一般使用jieba分词 1.安装 pip install jieba 2.大致了解jieba分词 包括jieba分词的3种模式 全模式 import jieba seg_list = jieb ...