XMOJ 1133: 膜拜大牛 计算几何/两圆相交
1133: 膜拜大牛
Time Limit: 1 Sec Memory Limit: 131072KiB
Submit: 9619 Solved: 3287
题目连接
http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1133
Description
Input
下面T组数据,每一组数据的第一行为一个正整数N(1<=N<=50),代表当地大牛的数量。接下来N行,每行有三个整数Xi Yi Wi(-20,000<=Xi,Yi<=20,000, 0<=Wi<=10^6),分别表示第i位大牛在地图上的横纵坐标和它的NB度,这个位置可以看成是一个面积为0的点。每组数据的最后一行是一个整数R(1<=R<=20,000),表示wywcgs脑袋的半径。
Output
Sample Input
4
0 -10 1
0 10 1
-10 0 1
10 0 1
10
4
0 -10 1
0 10 1
-10 0 1
10 0 1
8
Sample Output
2
HINT
题解:
圆交点的最大值,转化为圆弧被多少个圆覆盖的问题
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/*
inline ll read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
*/
//************************************************************************************** const double eps = 1e-;
const double pi = acos(-1.0);
const int N = ; struct point
{
double x,y;
int nb;
}p[N]; int n,r; struct alpha
{
double v;
int nb;
int flag;
bool friend operator <(const alpha &a,const alpha &b)
{
if(abs(a.v-b.v)<=eps)
return a.flag>b.flag;
else
return a.v < b.v;
}
}alp[N * ]; double dis(point a, point b)
{
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
} void solve(double R)
{
int ans = ;
double theta,phi,dist;
int i,j;
for( i = ;i < n;i++)
{
int k = ;
for( j = ;j < n;j++)
{
if(i == j) continue;
dist = dis(p[i],p[j]);
if(dist - 2.0 * R > eps)//判断是否有交点
continue;
theta = atan2(p[j].y - p[i].y, p[j].x - p[i].x);//这条直线的斜率
if(theta < eps)
theta += * pi;
phi = acos(dist / (2.0 * R));
alp[k].v = theta - phi + * pi;
alp[k].flag = ;
alp[k].nb=p[j].nb; alp[k + ].v = theta + phi + * pi;
alp[k + ].flag = ;
alp[k+].nb=p[j].nb;
k += ;
}
sort(alp,alp + k);
int sum = p[i].nb;
ans=max(sum,p[i].nb);
for( j = ;j < k;j++)
{
if(alp[j].flag)
sum +=alp[j].nb;
else
sum -=alp[j].nb;
if(sum > ans)
ans = sum;
}
}
printf("%d\n",ans );
} int main()
{
int i,j,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=;i<n;i++)
{
int x,y;
int nb;
scanf("%d %d %d",&x,&y,&nb);
p[i].x=double(x);
p[i].y=double(y);
p[i].nb=nb;
}
scanf("%d",&r);
solve(double(r));
}
return ;
}
XMOJ 1133: 膜拜大牛 计算几何/两圆相交的更多相关文章
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...
- 两圆相交求面积 hdu5120
转载 两圆相交分如下集中情况:相离.相切.相交.包含. 设两圆圆心分别是O1和O2,半径分别是r1和r2,设d为两圆心距离.又因为两圆有大有小,我们设较小的圆是O1. 相离相切的面积为零,代码如下: ...
- 求两圆相交部分面积(C++)
已知两圆圆心坐标和半径,求相交部分面积: #include <iostream> using namespace std; #include<cmath> #include&l ...
- UVALive 4428 Solar Eclipse --计算几何,圆相交
题意:平面上有一些半径为R的圆,现在要在满足不与现有圆相交的条件下放入一个圆,求这个圆能放的位置的圆心到原点的最短距离. 解法:我们将半径扩大一倍,R = 2*R,那么在每个圆上或圆外的位置都可以放圆 ...
- hdu 3264 09 宁波 现场 E - Open-air shopping malls 计算几何 二分 圆相交面积 难度:1
Description The city of M is a famous shopping city and its open-air shopping malls are extremely at ...
- LightOJ 1118--Incredible Molecules(两圆相交)
1118 - Incredible Molecules PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Lim ...
- hdu5858 Hard problem(求两圆相交面积)
题目传送门 Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- poj2546Circular Area(两圆相交面积)
链接 画图推公式 这两种情况 都可用一种公式算出来 就是两圆都求出圆心角 求出扇形的面积减掉三角形面积 #include <iostream> using namespace std; # ...
- hdu 5120 (求两圆相交的面积
题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...
随机推荐
- mysql远程连接数据库
配置mysql允许远程连接的方法. (1)查看3306端口状态 netstat -an | grep 3306 (2)修改mysql配置文件 ubuntu系统:vim /etc/mysql/mysql ...
- 数据库-mysql视图
视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用 一:创建视图 create view view ...
- TF-池化函数 tf.nn.max_pool 的介绍
转载自此大神 http://blog.csdn.net/mao_xiao_feng/article/details/53453926 max pooling是CNN当中的最大值池化操作,其实用法和卷积 ...
- java基础81 jsp的内置对象(网页知识)
1.什么是内置对象? 在jsp开发中,会频繁使用到一些对象,如:HttpSession,ServletContext,HttpServletRequest. 如果每次使用这些对象时,都要去创 ...
- android解决AVD中文路径无法启动问题
在as中新建一个AVD,然而启动时却报错,总之是不能找到中文路径 然后这个虚拟设备被默认安装在了C盘我的用户李敏啊,而我用户名是中文名导致无法识别 解决办法,使用链接文件格式修改虚拟设备配置路径, 比 ...
- 面试经典问题---数据库索引B+、B-树
具体讲解之前,有一点,再次强调下:B-树,即为B树.因为B树的原英文名称为B-tree,而国内很多人喜欢把B-tree译作B-树,其实,这是个非常不好的直译,很容易让人产生误解.如人们可能会以为B-树 ...
- JavaScript 中的回调函数
原文:http://javascriptissexy.com/ 翻译:http://blog.csdn.net/luoweifu/article/details/41466537 [建议阅读原文,以下 ...
- SQLServer系统变量使用
1.@@IDENTITY返回最后插入的标识值.这个变量很有用,当你插入一行数据时,想同时获得该行的的ID(标示列),就可以用@@IDENTITY示例:下面的示例向带有标识列的表中插入一行,并用 @@I ...
- CSS常见简写规则整理
外边距(margin) margin-top margin-right margin-bottom margin-left 简写顺序为顺时针方向(上.右.下.左),如:margin: 1px 2px ...
- 《精通Python设计模式》学习之工厂方法
小书,在我以前作数据库的连接时,就用了这个工厂方法的. 归纳总结一下,更有利于成长吧. import xml.etree.ElementTree as etree import json class ...