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 ...
随机推荐
- RedisTemplate使用
RedisTemplate中定义了对5种数据结构操作 redisTemplate.opsForValue();//操作字符串 redisTemplate.opsForHash();//操作hash r ...
- [shell]shell中if语句的使用
转自:http://lovelace.blog.51cto.com/1028430/1211353 bash中如何实现条件判断?条件测试类型: 整数测试 字符测试 文件测试 一.条件 ...
- 关于 JVM 内存的 N 个问题(转)
JVM的内存区域是怎么划分的? JVM的内存划分中,有部分区域是线程私有的,有部分是属于整个JVM进程:有些区域会抛出OOM异常,有些则不会,了解JVM的内存区域划分以及特征,是定位线上内存问题的基础 ...
- day05作业
一.1.switch 2.字符串 3.表达式1 4.break 5.continue 二.1.B 2.A 3.BD 4.D 5.B 6.B 7.A 8.D 9.D 10.B 三.1.√ 2.√ 3.× ...
- Linux入门(二)Shell基本命令
上一篇讲了普通用户切换到root用户,今天补充一点,对于Debian和Ubuntu用户,安装时候只有一个普通用户注册,在需要root权限时,我们可以在普通用户模式下输入sudo这个命令运行某些相关特权 ...
- Python基础 - MySQLdb模块
安装 pip install MySQLdb 使用 去除一个数据库中所有的表 import MySQLdb def db_test(): conn = MySQLdb.connect(user='&l ...
- Centos简介
Centos作为主流的一种Linux操作系统,以后项目中,比如后期Redis,以及部署一些项目,会把Centos作为服务器操作系统,我们选用Centos,主要是免费,以及稳定. Centos详细介绍, ...
- Zookeeper安装以及配置说明(三)
Zookeeper的安装和配置非常的简单,既可以配置成单机模式,也可以配置成集群模式.如下图所示: 下面将分别进行介绍: 单机模式 下载最新稳定版本zookeeper的安装包之后(看第一篇博文), 解 ...
- Struts DynaActionForm example
The Struts DynaActionForm class is an interesting feature to let you create a form bean dynamically ...
- #JS Regex正则表达式的使用
字符串带的正则表达式相关的方法 1.search() 搜索符合指定正则表达式在目标字符串中的位置 str.search('hello'); //str字符串中查找search字符串,成功返回位置,否则 ...