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 ...
随机推荐
- aarch64_g3
glibc-langpack-wal-2.25-6.fc26.aarch64.rpm 2017-06-20 17:08 210K fedora Mirroring Project glibc-lang ...
- Linux下MySQL/MariaDB Galera集群搭建过程【转】
MariaDB介绍 MariaDB是开源社区维护的一个MySQL分支,由MySQL的创始人Michael Widenius主导开发,采用GPL授权许可证. MariaDB的目的是完全兼容MySQL,包 ...
- mysql -> 启动&多实例_03
常用的连接方式: 套接字: mysql -uroot -p123 -S /application/mysql/tmp/mysql.sock Tcp/Ip: mysql -uroot -p123 -h ...
- 列表选择Spinner
1.只用XML配置来显示列表 在res\values中添加一个arrays.xml 1 <?xml version="1.0" encoding="utf-8&qu ...
- React 学习二 组件
React的一个最大的特点就是组件化的开发模式.今天就来试一下: <!DOCTYPE html> <html> <head> <meta charset=&q ...
- 洛谷P2296寻找道路
传送门啦 题目中有一个条件是路径上的所有点的出边所指向的点都直接或间接与终点连通. 所以我们要先判断能否走这一个点, $ bfs $ 类似 $ spfa $ 的一个判断,打上标记. 在这我反向建图,最 ...
- Radon变换——MATLAB
算法说明: 图像的Radon变换是每个像素的Radon变换的总和. 该算法首先将图像中的像素分成四个子像素,并分别投影每个子像素,如下图所示. 根据投影位置和箱体中心之间的距离,每个子像素的贡献按比例 ...
- git获取帮助
想了解 Git 的各式工具该怎么用,可以阅读它们的使用帮助,方法有三: $ git help <verb> $ git <verb> --help $ man git-< ...
- java 工厂模式和内部类的完美结合
package com.bikeqx.test; public class Main{ public static void apply(ServiceFactory sf){ Service s = ...
- 牛客网 桂林电子科技大学第三届ACM程序设计竞赛 G.路径-带条件的树的直径变形-边权最大,边数偶数的树上的最长路径-树形dp
链接:https://ac.nowcoder.com/acm/contest/558/G 来源:牛客网 路径 小猫在研究树. 小猫在研究路径. 给定一棵N个点的树,每条边有边权,请你求出最长的一条路径 ...