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 ...
随机推荐
- rsync本地及远程复制备份【原创】
1.安装rsyncyum instsall rsync 2.本地复制 rsync -auq --progress --delete /tongbu1/ /tongbu2/ rsync -auq --p ...
- 十、springcloud之Consul注销实例
@Autowired //com.ecwid.consul.v1.ConsulClient private ConsulClient consulClient; @PostMapping(" ...
- python网络编程-socketserver
一:socketserver简化了网络服务器的编写. 它有4个类:TCPServer,UDPServer,UnixStreamServer,UnixDatagramServer. 这4个类是同步进行处 ...
- Flask form
用户登录 #!/usr/bin/env python # -*- coding:utf- -*- from flask import Flask, render_template, request, ...
- MICROSOFT SQLSERVER 总结
--语 句 功 能--数据操作Select --从数据库表中检索数据行和列Insert --向数据库表添加新数据行Delete --从数据库表中删除数据行Update --更新数据库表中的数据--数据 ...
- CVE-2012-0003 Microsoft Windows Media Player ‘winmm.dll’ MIDI文件解析远程代码执行漏洞 分析
[CNNVD]Microsoft Windows Media Player ‘winmm.dll’ MIDI文件解析远程代码执行漏洞(CNNVD-201201-110) Microsoft Wi ...
- 一行代码实现Okhttp,Retrofit,Glide下载上传进度监听
https://mp.weixin.qq.com/s/bopDUFMB7EiK-MhLc3KDXQ essyan 鸿洋 2017-06-29 本文作者 本文由jessyan投稿. jessyan的博客 ...
- CCF CSP 201612-3 权限查询
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201612-3 权限查询 问题描述 授权 (authorization) 是各类业务系统不可缺 ...
- centos6.5/6.3升级安装ImageMagick7.0.1-1
线上论坛和应用程序的验证码功能都是使用的ImageMagick,但是版本比较老(centos yum安装的ImageMagick6.5.9).接到最新漏洞预报,紧急升级! ImageMagick图象处 ...
- 【LOJ】#2038. 「SHOI2015」超能粒子炮・改
题解 用lucas随便分析一波就出来了 \(\binom{n}{k} = \binom{n % p}{k % p}\binom{n / p}{k / p}\) 那么对于一个余数r,如果r <= ...