Catching Fish

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1741    Accepted Submission(s): 686

Problem Description
Ignatius
likes catching fish very much. He has a fishnet whose shape is a circle
of radius one. Now he is about to use his fishnet to catch fish. All
the fish are in the lake, and we assume all the fish will not move when
Ignatius catching them. Now Ignatius wants to know how many fish he can
catch by using his fishnet once. We assume that the fish can be regard
as a point. So now the problem is how many points can be enclosed by a
circle of radius one.

Note: If a fish is just on the border of the fishnet, it is also caught by Ignatius.

 
Input
The
input contains several test cases. The first line of the input is a
single integer T which is the number of test cases. T test cases follow.
Each
test case starts with a positive integer N(1<=N<=300) which
indicate the number of fish in the lake. Then N lines follow. Each line
contains two floating-point number X and Y (0.0<=X,Y<=10.0). You
may assume no two fish will at the same point, and no two fish are
closer than 0.0001, no two fish in a test case are approximately at a
distance of 2.0. In other words, if the distance between the fish and
the centre of the fishnet is smaller 1.0001, we say the fish is also
caught.
 
Output
For each test case, you should output the maximum number of fish Ignatius can catch by using his fishnet once.
 
Sample Input
4
3
6.47634 7.69628
5.16828 4.79915
6.69533 6.20378
6
7.15296 4.08328
6.50827 2.69466
5.91219 3.86661
5.29853 4.16097
6.10838 3.46039
6.34060 2.41599
8
7.90650 4.01746
4.10998 4.18354
4.67289 4.01887
6.33885 4.28388
4.98106 3.82728
5.12379 5.16473
7.84664 4.67693
4.02776 3.87990
20
6.65128 5.47490
6.42743 6.26189
6.35864 4.61611
6.59020 4.54228
4.43967 5.70059
4.38226 5.70536
5.50755 6.18163
7.41971 6.13668
6.71936 3.04496
5.61832 4.23857
5.99424 4.29328
5.60961 4.32998
6.82242 5.79683
5.44693 3.82724
6.70906 3.65736
7.89087 5.68000
6.23300 4.59530
5.92401 4.92329
6.24168 3.81389
6.22671 3.62210
 
Sample Output
2
5
5
11
模板题:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
using namespace std;
const int N = ;
struct Point
{
double x,y;
} p[N];
struct Node
{
double angle;
bool in;
} arc[];
int n,cnt;
double R;
double dist(Point p1,Point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
bool cmp(Node n1,Node n2)
{
return n1.angle!=n2.angle?n1.angle<n2.angle:n1.in>n2.in;
}
void MaxCircleCover()
{
int ans=;
for(int i=; i<n; i++)
{
int cnt=;
for(int j=; j<n; j++)
{
if(i==j) continue;
if(dist(p[i],p[j])>R*) continue;
double angle=atan2(p[i].y-p[j].y,p[i].x-p[j].x);
double phi=acos(dist(p[i],p[j])/);
arc[cnt].angle=angle-phi;
arc[cnt++].in=true;
arc[cnt].angle=angle+phi;
arc[cnt++].in=false;
}
sort(arc,arc+cnt,cmp);
int tmp=;
for(int i=; i<cnt; i++)
{
if(arc[i].in) tmp++;
else tmp--;
ans=max(ans,tmp);
}
}
printf("%d\n",ans);
}
int main()
{
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
scanf("%d",&n);
//scanf("%lf",&R);
R = ; //此题 R 为 1
for(int i=; i<n; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
MaxCircleCover();
}
return ;
}

hdu 1077(单位圆覆盖问题)的更多相关文章

  1. bzoj1338: Pku1981 Circle and Points单位圆覆盖

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1338 1338: Pku1981 Circle and Points单位圆覆盖 Time ...

  2. 线段树扫描线(一、Atlantis HDU - 1542(覆盖面积) 二、覆盖的面积 HDU - 1255(重叠两次的面积))

    扫描线求周长: hdu1828 Picture(线段树+扫描线+矩形周长) 参考链接:https://blog.csdn.net/konghhhhh/java/article/details/7823 ...

  3. HDU 1077 Catching Fish(用单位圆尽可能围住多的点)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1077 Catching Fish Time Limit: 10000/5000 MS (Java/Oth ...

  4. hdu 1077 (圆交)

    Problem - 1077 我们可以知道,当这个单位圆可以覆盖到最多的点的时候,必定最少有两个点位于这个圆的圆周上,于是就有网上众多的O(N^3)的枚举两个在圆上的点的暴搜做法. 然而这题是可以用圆 ...

  5. POJ-1981 Circle and Points 单位圆覆盖

    题目链接:http://poj.org/problem?id=1981 容易想到直接枚举两个点,然后确定一个圆来枚举,算法复杂度O(n^3). 这题还有O(n^2*lg n)的算法.将每个点扩展为单位 ...

  6. poj1981 Circle and Points 单位圆覆盖问题

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Circle and Points Time Limit: 5000MS   Me ...

  7. (水题)HDU - 1077 - Catching Fish - 计算几何

    http://acm.hdu.edu.cn/showproblem.php?pid=1077 很明显这样的圆,必定有两个点在边界上.n平方枚举圆,再n立方暴力判断.由于没有给T,所以不知道行不行.

  8. 【 HDU 1255】 覆盖的面积(矩阵面积交,线段树,扫描法)

    [题目] 覆盖的面积 Problem Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input 输入数据的第一行是一个正整数T(1<=T<=100 ...

  9. HDU 1077

    题意 : 给你 N 个点, 问一个单位圆最大能包括几个点 直接暴力枚举圆心, 计算个数        O(n^ 3): 精度,细节都要注意, //#include<bit/stdc++.h> ...

随机推荐

  1. 【dp】P1077 摆花

    基础DP题 题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号.为了在门口展出更多种花,规定第i种花不能超过a ...

  2. 【dp】P1982 小朋友的数字

    有趣的细节题目 题目描述 有 n 个小朋友排成一列.每个小朋友手上都有一个数字,这个数字可正可负.规定每个小朋友的特征值等于排在他前面(包括他本人)的小朋友中连续若干个(最少有一个)小朋友手上的数字之 ...

  3. Flask初学者:Jinja2模板

    Python的Jinja2模板,其实就是在HTML文档中使用控制语句和表达语句替换HTML文档中的变量来控制HTML的显示格式,Python的Jinja2模板可以更加灵活和方便的控制HTML的显示,而 ...

  4. IAR生成bin,HEX文件

    1.生成bin,hex文件 options->output converter->output format binary:.bin文件:intel extended:hex文件. 生成的 ...

  5. 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven

    131072K   One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...

  6. BZOJ 4479: [Jsoi2013]吃货jyy

    一句话题意:求必须包含某K条边的回路(回到1),使得总权值最小 转化为权值最小的联通的偶点 令F[i]表示联通状态为i的最小权值,(3^n状压)表示不在联通块内/奇点/偶点,连边时先不考虑必选的边的度 ...

  7. 以http server为例简要分析netty3实现

    概要 最近看了点netty3实现.从webbit项目作为口子.webbit项目是一个基于netty3做的http与websocket server.后面还会继续看下netty4,netty4有很多改进 ...

  8. webdriver高级应用- 启动FireFox的同时打开Firebug

    1. 首先本机Firefox浏览器需要安装一下firebug插件,具体怎么安装这里不赘述,网上教程很多. 2. 具体自动化实现的代码如下: #encoding=utf-8 from selenium ...

  9. Selenium WebDriver-通过断言页面是否存在某些关键字来确定页面按照预期加载

    #encoding=utf-8 import unittest import time import chardet from selenium import webdriver class Visi ...

  10. Web网站性能测试分析及调优实例

    1 背景   前段时间,性能测试团队经历了一个规模较大的门户网站的性能优化工作,该网站的开发和合作涉及多个组织和部门,而且网站的重要性不言而喻,同时上线时间非常紧迫,关注度也很高,所以对于整个团队的压 ...