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的更多相关文章

  1. poj 1106 Transmitters (叉乘的应用)

    http://poj.org/problem?id=1106 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4488   A ...

  2. poj 1106 Transmitters (枚举+叉积运用)

    题目链接:http://poj.org/problem?id=1106 算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小 ...

  3. POJ 1106 Transmitters(计算几何)

    题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...

  4. poj 1106(半圆围绕圆心旋转能够覆盖平面内最多的点)

    Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4955   Accepted: 2624 Desc ...

  5. POJ 1106

    先判断是否在圆内,然后用叉积判断是否在180度内.枚举判断就可以了... 感觉是数据弱了.. #include <iostream> #include <cstdio> #in ...

  6. [转] POJ计算几何

    转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...

  7. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

  8. poj1106 Transmitters

    地址:http://poj.org/problem?id=1106 题目: Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total S ...

  9. 【解题报告】POJ-1106 Transmitters

    原题地址:http://poj.org/problem?id=1106 题目大意: 给定一些平面的点以及一个圆心和半径,过圆心作一个半圆,求点在半圆中点最多多少个. 解题思路: 首先将给定点中和圆心的 ...

随机推荐

  1. [ZJOI2011]道馆之战

    Description 口袋妖怪(又名神奇宝贝或宠物小精灵)红/蓝/绿宝石中的水系道馆需要经过三个冰地才能到达馆主的面前,冰地中的每一个冰块都只能经过一次.当一个冰地上的所有冰块都被经过之后,到下一个 ...

  2. 1.1.2最小生成树(Kruskal和Prim算法)

    部分内容摘自 勿在浮沙筑高台 http://blog.csdn.net/luoshixian099/article/details/51908175 关于图的几个概念定义: 连通图:在无向图中,若任意 ...

  3. magento 用程序生成优惠劵码

    参考自http://fragmentedthought.com/fragments/programatically-creating-sales-rule-coupon-code 上面的代码只能生成C ...

  4. JEECMS9.3集成dubbo操作记录

    需求描述: 门户及其他应用系统需要查询JEECMS9.3中发布的栏目及数据,而其他系统都是基于dubbo开发的,因此想要将JEECMS9.3中集成dubbo并对外提供内容管理服务. 需求实现: 1.添 ...

  5. 分享一款强大的图片查看器插件,手机PC 通吃,功能超级齐全!

    一款强大的图片查看器插件,手机PC 通吃,功能超级齐全! 地址:http://photoswipe.com/

  6. poj2393 Yogurt factory

    思路: 贪心. 实现: #include <iostream> #include <cstdio> #include <algorithm> using names ...

  7. Vue.js学习笔记--2.基础v-指令

    整理自官网教程 -- https://cn.vuejs.org/ 1. v-bind绑定Class与Style a. 绑定Class 语法:v-bind:class="{classname: ...

  8. 关于react native在window下运行安卓的时候报 could not connect to development server

    当出现这种问题是网上的解答方案都是一模一样的! 我这边先给个地址讲的是解决方案http://blog.csdn.net/qq_25827845/article/details/52974991 但是我 ...

  9. java设计模式之代理模式 ,以及和java 回调机制的区别

    java 代理模式就是: 将自己要做的事交给别人去做(这个别人就是代理者,自己就是被代理者),为什么自己能做的要交给别人去做了?假如一个小学生小明,现在要写作业,但是又想玩游戏,他更想玩游戏,并且不想 ...

  10. 习水医院12C RAC 数据库安装文档

        环境介绍 OS: Oracle Enterprise Linux 6.4 (For RAC Nodes) DB: GI and Database 12.1.0.2 所需介质 p17694377 ...