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 题目大意: 给定一些平面的点以及一个圆心和半径,过圆心作一个半圆,求点在半圆中点最多多少个. 解题思路: 首先将给定点中和圆心的 ...
随机推荐
- Noip2014生活大爆炸版石头剪刀布【水模拟】
模拟暴力也要优雅. https://www.luogu.org/problemnew/show/P1328 像我这种蒟蒻就会敲无数个ifelse qaq. 可以优雅地进行预处理一下. 膜法真是好东西q ...
- iOS APNs远程推送流程精简版
1.去Apple Developer Center里创建应用的信息,指定APP ID(Bundle ID),配置里开启推送功能(Push Notifications). 后续步骤需要用到这个应用的包名 ...
- IE6 position:fixed bug hack方式
/* IE6浏览器的特有方法 */ /* 修正IE6振动bug */ * html,* html body{background-image:url(about:blank);background-a ...
- 题解报告:hdu 1114 Piggy-Bank(完全背包恰好装满)
Problem Description Before ACM can do anything, a budget must be prepared and the necessary financia ...
- 题解报告:poj 2503 Babelfish(map)
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensib ...
- PHP autoload实践
本文目的 本文简要的描述了PHP提供的autoload机制,以及在scake中使用实践.用于减少不必要的文件包含,提高php系统性能. 什么是__autoload php是脚本语言,不同于c++只需要 ...
- 199 Binary Tree Right Side View 二叉树的右视图
给定一棵二叉树,想象自己站在它的右侧,返回从顶部到底部看到的节点值.例如:给定以下二叉树, 1 <--- / \2 3 <--- \ ...
- Oracle用户角色权限相关视图
常用相关视图概述 DBA_SYS_PRIVS: 查询某个用户所拥有的系统权限 USER_SYS_PRIVS: 当前用户所拥有的系统权限 SESSION_PRIVS: 当前用户所拥有的全部权限 ROLE ...
- 在Stuts2中使用ModelDriven action
在Struts2中,提供了另外一种直接使用领域对象的方式,那就是让action实现com.opensymphony.xwork2.ModelDriven接口.ModelDriven让你可以直接操作应用 ...
- JDK集合框架--综述
接下来的几篇博客总结一下对jdk中常用集合类知识,本篇博客先整体性地介绍一下集合及其主要的api: 从整体上来说,集合分两大类collection和map: 首先来看看Collection: c ...