Poj 1106 Transmitters
Poj 1106 Transmitters
给出一个半圆,可以任意旋转,问这个半圆能够覆盖的最多点数。
我们枚举每一个点作为必然覆盖点,那么使用叉积看极角关系即可判断其余的点是否能够与其存在一个半圆内
import java.io.*;
import java.util.*;
public class Main {
static class Point implements Comparable<Point> {
double x, y;
@Override
public int compareTo(Point a) {
return (int) cross(a);
}
public double cross(Point a) {
return a.x * y - x * a.y;
}
}
static double cross(Point st, Point a, Point b) {
return (a.x - st.x) * (b.y - st.y) - (b.x - st.x) * (a.y - st.y);
}
static double dist(Point a1, Point a2) {
return (a1.x - a2.x) * (a1.x - a2.x) + (a1.y - a2.y) * (a1.y - a2.y);
}
static final int N = 10005;
static final int inf = 0x3f3f3f3f;
static final double eps = 1e-9;
static Point a[] = new Point[N];
public static void main(String[] args) {
Scanner cin = new Scanner(new InputStreamReader(System.in));
while (cin.hasNext()) {
Point st = new Point(), tmp = new Point();
st.x = cin.nextDouble();
st.y = cin.nextDouble();
double r = cin.nextDouble();
double d;
int n = cin.nextInt();
int cnt = 0;
for (int i = 0; i < n; i++) {
tmp.x = cin.nextDouble();
tmp.y = cin.nextDouble();
d = dist(st, tmp);
if (d < r * r || Math.abs(d - r * r) < eps) {
cnt++;
if (a[cnt] == null)
a[cnt] = new Point();
a[cnt].x = tmp.x;
a[cnt].y = tmp.y;
}
}
int ans = 0;
for (int i = 1; i <= cnt; i++) {
int count = 1;
for (int j = 1; j <= cnt; j++) {
if (i != j && cross(st, a[i], a[j]) <= 0)
count++;
}
if (count > ans)
ans = count;
}
System.out.println(ans);
}
cin.close();
}
}
Poj 1106 Transmitters的更多相关文章
- poj 1106 Transmitters (叉乘的应用)
http://poj.org/problem?id=1106 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4488 A ...
- poj 1106 Transmitters (枚举+叉积运用)
题目链接:http://poj.org/problem?id=1106 算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小 ...
- POJ 1106 Transmitters(计算几何)
题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...
- poj 1106(半圆围绕圆心旋转能够覆盖平面内最多的点)
Transmitters Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4955 Accepted: 2624 Desc ...
- POJ 1106
先判断是否在圆内,然后用叉积判断是否在180度内.枚举判断就可以了... 感觉是数据弱了.. #include <iostream> #include <cstdio> #in ...
- [转] POJ计算几何
转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...
- ACM计算几何题目推荐
//第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...
- poj1106 Transmitters
地址:http://poj.org/problem?id=1106 题目: Transmitters Time Limit: 1000MS Memory Limit: 10000K Total S ...
- 【解题报告】POJ-1106 Transmitters
原题地址:http://poj.org/problem?id=1106 题目大意: 给定一些平面的点以及一个圆心和半径,过圆心作一个半圆,求点在半圆中点最多多少个. 解题思路: 首先将给定点中和圆心的 ...
随机推荐
- X86 Linux 下 SIGBUS 总结
SIGBUS 在 x86 Linux 上并不多见,但一旦出现,其调用堆栈常常让人摸不着头脑,加之信号问题各平台系统间差异较大,更让人难以理清,这里稍微总结一下 x86 Linux 上大概有哪些情形会触 ...
- 转 11g RAC R2 体系结构---Grid
基于agent的管理方式 从oracle 11.2开始出现了多用户的概念,oracle开始使用一组多线程的daemon来同时支持多个用户的使用.管理资源,这些daemon叫做Agent.这些Agent ...
- String的用法——获取功能
package cn.itcast_04; /* String类获取功能 int length():获取字符的长度 char charAt(int index):获取指定索引位置的字符 int ind ...
- AJPFX关于Collection 集合的表述
集合的遍历class Demo_Collection{ public static void main(String[] args){ Collection c = new ...
- fatal: Authentication failed for 问题解决
执行以下code git config --system --unset credential.helper 参考地址: https://www.jianshu.com/p/8a7f257e07b8
- 字符串(String)几个常用方法的详解
String:(字符串) indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置. stringObject.indexOf(searchvalue,fromindex) searc ...
- flex布局(主要分清楚容器和条目)
设置在容器上面的属性:flex-direction.flex-wrap.flex-flow.justify-content.align-items.align-content1.flex-direct ...
- chosen-bootstrap使用技巧
1.页面加载完成后,通过js方式设置值,无法有效显示的问题. 解决:先设置值,让后在进行初始化操作. // 设置select选中值 $("#type").val(type); // ...
- freopen()重定向的打开和关闭
freopen函数 功能 使用不同的文件或模式重新打开流,即重定向. 实现重定向,把预定义的标准流文件定向到由path指定的文件中.(直观感觉/实际操作都像是把文件定向到流,难道是说,对流来说就是重定 ...
- splice用法解析
splice()方法算是最强大的数组方法了,它有很多种用法,主要用于删除指定位置的数组项,在指定的位置插入数组项,在指定位置替换数组项,slpice()方法始终都会返回一个数组,该数组包括从原始数组中 ...