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 ...
随机推荐
- go 数组
数组的定义和 初始化 数组是同一类型的元素集合 ]int //定义⼀个数组 Go中数组下标从0开始,因此长度为n的数组下标范围:[0,n-1] 整数数组中的元素默认初始化为0,字符串数组中的元素默认初 ...
- Shell编写8点建议
这八个建议,来源于键者几年来编写 shell 脚本的一些经验和教训.事实上开始写的时候还不止这几条,后来思索再三,去掉几条无关痛痒的,最后剩下八条.毫不夸张地说,每条都是精挑细选的,虽然有几点算是老生 ...
- python并发爬虫利器tomorrow(一)
tomorrow是我最近在用的一个爬虫利器,该模块属于第三方的一个模块,使用起来非常的方便,只需要用其中的threads方法作为装饰器去修饰一个普通的函数,既可以达到并发的效果,本篇将用实例来展示to ...
- C基础 旋转数组查找题目
前言 - 引言 题目: 一类有序数组旋转查值问题. 例如: 有序数组 [ , , , , , , , , ] 旋转后为 [ , , , , , , , , ] 如何从中找出一个值索引, not fou ...
- Python之 context manager
在context manager中,必须要介绍两个概念: with as... , 和 enter , exit. 下文将先介绍with语句,然后介绍 __enter__和exit, 最后介绍cont ...
- K/V式枚举
public enum OType { LOGIN { public String getDesc() { return "登录"; } }, ADD { public Strin ...
- C++中关于位域的概念
原文来自于http://topic.csdn.net/t/20060801/11/4918904.html中的回复 位域 有些信息在存储时,并不需要占用一个完整的字节, 而只需占几个或一个二进制位 ...
- js中字符串的常用方法
一.普通方法 1.字符方法 动态方法:1.str.charAt(index); 返回子字符串,index为字符串下标,index取值范围[0,str.length-1] 动态方法:2.str.cha ...
- MySQL5.6 Waiting for Commit Lock
mysql Bug#19843808 自动修复记录 MySQL5.6和Xtrabackup之间存在一个bug,这个bug在5.6.23中已经修复. Xtrabackup备份的时候执行flushs t ...
- Caffe训练AlexNet网络模型——问题二
训练时,出现Check failed:error == cudaSuccess (2 vs. 0) out of memory,并且accruary = 0,如下图所示: 解决方法:将train_va ...