Catching Fish[HDU1077]
Catching Fish
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1052 Accepted Submission(s): 385
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
Author
Ignatius.L
#include <cmath>
#include <cstdio> using namespace std; const static double eps = 1e-; struct Point
{
double x,y;
};
double distancess(Point a,Point b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
Point look_center(Point a,Point b)
{
Point aa,bb,mid;
aa.x = b.x-a.x;
aa.y = b.y-a.y;
mid.x = (a.x+b.x)/2.0;
mid.y = (a.y+b.y)/2.0;
double dist = distancess(a,mid);
double c = sqrt(1.0-dist);
if(fabs(aa.y)<eps)
{
bb.x = mid.x;
bb.y = mid.y+c;
} else
{
double ang = atan(-aa.x/aa.y);
bb.x = mid.x + c*cos(ang);
bb.y = mid.y + c*sin(ang);
}
return bb;
}
int main()
{
int test;
Point p[],a,b,c;
int n;
scanf("%d",&test);
while(test--)
{
scanf("%d",&n);
for(int i=; i<n;i++)
scanf("%lf%lf",&p[i].x,&p[i].y); int ans = ;
int temp = ;
for(int i=; i<n; i++)
for(int j=i+;j<n;j++)
{ if(distancess(p[i],p[j])>) continue;
a = look_center(p[i],p[j]);
temp = ;
for(int k=;k<n;k++)
{
if(distancess(a,p[k])<=1.000001) temp++;
}
if(ans<temp) ans = temp;
}
printf("%d\n",ans);
}
return ; }
Catching Fish[HDU1077]的更多相关文章
- hduoj 1077 Catching Fish 求单位圆最多覆盖点个数
Catching Fish Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1077 Catching Fish(用单位圆尽可能围住多的点)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1077 Catching Fish Time Limit: 10000/5000 MS (Java/Oth ...
- (水题)HDU - 1077 - Catching Fish - 计算几何
http://acm.hdu.edu.cn/showproblem.php?pid=1077 很明显这样的圆,必定有两个点在边界上.n平方枚举圆,再n立方暴力判断.由于没有给T,所以不知道行不行.
- HDU 1077Catching Fish(简单计算几何)
Catching Fish Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- Lesson 20 One man in a boat
Text Fishing is my favourite sport. I often fish for hours without catching anything. But this does ...
- NCE2
1.A private conversation Last week I went to the theatre. I had a very good seat. The play was very ...
- New Concept English Two 9 22
The video can be found on the website. $课文20 独坐孤舟 190. Fishing is my favourite sport. 钓鱼是我特别喜爱的一项运动. ...
- 2018年暑假ACM个人训练题7 题解报告
A:HDU 1060 Leftmost Digit(求N^N的第一位数字 log10的巧妙使用) B:(还需要研究一下.....) C:HDU 1071 The area(求三个点确定的抛物线的面积, ...
- hdu 1077(单位圆覆盖问题)
Catching Fish Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
随机推荐
- C#内部类
http://blog.csdn.net/yanghua_kobe/article/details/6685222 在<Java编程思想>中花了一章的篇幅介绍,内部类的相关特性.而在C#的 ...
- unity3d 参考坐标系
原地址:http://www.cnblogs.com/88999660/archive/2013/04/01/2993844.html 参考坐标系(Reference Coordinate Syste ...
- Linux rpm安装问题解决
1.安装时提示:warning: *.rpm: Header V3 RSA/SHA256 Signature, keykey ID c105b9de: NOKEY 解决的方法就是在rpm 语句后面加上 ...
- Linux 系统安全 抵御TCP的洪水
抵御TCP的洪水 分类: LINUX tcp_syn_retries :INTEGER默认值是5对 于一个新建连接,内核要发送多少个 SYN 连接请求才决定放弃.不应该大于255,默认值是5,对应于1 ...
- CentOS6.5以runlevel 3开机时自动连接某无线设置示例
[参考]http://blog.csdn.net/simeone18/article/details/8580592 [方法一] 假设无线网卡代号为wlan0,无线AP的essid为:TheWiFi, ...
- php中正则表达式的匹配和数据验证总结
正则表达式能匹配复杂的字符串形式,比字符串处理函数功能更加多,只不过执行效率有所降低,但是可以实现非常复杂的匹配,下面总结一下 1.简单的字符串匹配,判断指定字符串是不是在另一个字符串中,和字符串查找 ...
- DisJSet:食物链(POJ 1182)
动物王国的食物链 这一题有两种思路,先介绍第一种: 题目是中文的,我就不翻译了,也很好理解,就是一个A-B-C-A的一个循环的食物链,给定一些条件,问你哪些条件是错的 这一题,是一道比较 ...
- mongodb初步使用
下载安装: 下载MongoDB:http://www.mongodb.org/. 安装MongoDB:傻瓜式安装 配置: 把bin目录添加到系统环境变量 启动: 打开一个 cmd编辑框,输入: mon ...
- 线段覆盖4(codevs 3012)
题目描述 Description 数轴上有n条线段,线段的两端都是整数坐标,坐标范围在0~1000000,每条线段有一个价值,请从n条线段中挑出若干条线段,使得这些线段两两不覆盖(端点可以重合)且线段 ...
- python实现简单爬虫抓取图片
最近在学习python,正如大家所知,python在网络爬虫方面有着广泛的应用,下面是一个利用python程序抓取网络图片的简单程序,可以批量下载一个网站更新的图片,其中使用了代理IP的技术. imp ...