题目链接:http://codeforces.com/gym/102279/problem/H

大致题意: 你在一个定点,你有个长度为R的钩子,有n个东西在其他点处,问你能勾到的东西的数量是多少?

思路:明明一道几何题,罗老板居然用gcd巧妙的A了,真是太强了。如果一件物品挡住了另一件物品,那么它是勾不到的。

   首先将所有距离在R的点都拎出来,然后对于给定点进行极角排序,最后俩俩相邻比较即可确定答案。

AC代码:

 #include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const double eps = 1e-;
const int maxn = 5e5+;
int sgn(double x){
if(fabs(x) < ) return ;
else return x < ? - : ;
}
struct Point{
double x, y;
Point(){}
Point(double _x, double _y){
x = _x, y = _y;
}
void input(){
scanf("%lf%lf", &x, &y);
}
void output(){
printf("%.2f %.2f",x ,y);
}
bool operator == (Point b) const{
return sgn(x - b.x) == && sgn(y - b.y) == ;
}
bool operator < (Point b)const{
return sgn(x - b.x) == ? sgn(y - b.y < ) : x < b.x;
}
Point operator - (const Point &b)const{
return Point(x - b.x, y - b.y);
}
//叉积
double operator ^(const Point &b){
return x * b.y - y * b.x;
}
//点积
double operator *(const Point &b){
return x * b.x + y * b.y;
}
double distant(Point p){
return hypot(x - p.x, y - p.y);
} };
Point p[maxn];
struct cmp{
Point p;
cmp(const Point &p0) {p = p0;}
bool operator()(const Point &aa, const Point &bb){
Point a = aa, b = bb;
int d = sgn((a - p) ^ (b - p));
if(d == ){
return sgn(a.distant(p) - b.distant(p)) < ;
}
return d > ;
}
}; int main()
{
int n;
double x0, y0, r;
double x, y;
scanf("%lf %lf %lf %d",&x0, &y0, &r, &n);
int m = ;
Point s = Point(x0, y0), e;
while(n--){
e.input();
//printf("d = %.12f\n",e.distant(s) - r);
if(e.distant(s) - r <= )
p[m++] = e;
}
int ans = ;
sort(p, p + m, cmp(s));
for(int i = ;i < m;i++)
{
if(i == ) ans++;
else if(((p[i] - s) ^ (p[i-] - s)) != 0.0)
ans++;
}
printf("%d\n",ans);
return ;
}

附罗老板的神奇gcd:(明显代码长度短很多啊orz)

HCW 19 Team Round (ICPC format) H Houston, Are You There?(极角排序)的更多相关文章

  1. HCW 19 Team Round (ICPC format) B. Beggin' For A Node(树的重心,交互题)

    B. Beggin' For A Node time limit per test2.0 s memory limit per test256 MB inputstandard input outpu ...

  2. Codeforces Round #124 (Div. 1) C. Paint Tree(极角排序)

    C. Paint Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  3. Educational Codeforces Round 1 C. Nearest vectors 极角排序

    Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/ ...

  4. 2018 ICPC北京 H ac自动机

    n=40的01串,求有多少m=40的01串中包含它,包含的定义是存在子串有至多一个字符不相同 600组n=15的数据 15组n=40的数据,所以我们只能支持n^5的算法. 陷入两个比较有意思的坑: 1 ...

  5. icpc 银川 H. Delivery Route SPFA优化

    Problem Description Pony is the boss of a courier company. The company needs to deliver packages to ...

  6. Codeforces Round #292 (Div. 1) B. Drazil and Tiles 拓扑排序

    B. Drazil and Tiles 题目连接: http://codeforces.com/contest/516/problem/B Description Drazil created a f ...

  7. Codeforces Round #292 (Div. 2) D. Drazil and Tiles [拓扑排序 dfs]

    传送门 D. Drazil and Tiles time limit per test 2 seconds memory limit per test 256 megabytes Drazil cre ...

  8. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  9. Codeforces Round #541 (Div. 2) D 并查集 + 拓扑排序

    https://codeforces.com/contest/1131/problem/D 题意 给你一个n*m二维偏序表,代表x[i]和y[j]的大小关系,根据表构造大小分别为n,m的x[],y[] ...

随机推荐

  1. MacBook Pro常用快捷键

    MacBook Pro常用快捷键 Mac  fn + left / right / up / down 相当于 home/end/page up /page down delete 删除光标前一个字符 ...

  2. sqlserver定时作业,定时执行存储过程

    首先,我想说,我真的是渣了,一个这个玩意弄了半天,算了,直接切入正题吧. 第一步: 先写好存储过程 用了两张表,你们自己建立吧 <br data-filtered="filtered& ...

  3. 高级UI晋升之自定义View实战(五)

    更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680本篇文章将从自定义View利器Canvas和Paint来进行详解 一.Canvas ...

  4. 如何安装python运行环境Anaconda

    参考视频:https://v.qq.com/x/page/u05499rig9s.html

  5. docker部署一个简单的mian.py项目文件

    安装docker yum install -y docker  启动docker systemctl start docker   查询可安装的Python版本,默认centos python 2.7 ...

  6. css3新增(圆角边框(border-radius),盒子阴影(box-shadow),文字阴影(text-shadow),背景缩放(background-size))

    1.圆角边框  border-radius border-radius 属性用于设置元素的外边框圆角 语法:border-radius:length; 参数值可以是数值 或者 百分比 的形式 正方形, ...

  7. Shell 变量的分类

  8. 热修复框架Tinker的从0到集成之路(转)

    转自:http://blog.csdn.net/lisdye2/article/details/54411727 热修复框架Tinker的从0到集成之路 转载请标明出处: http://blog.cs ...

  9. C++如何阻止一个类被实例化

    (1)定义一个无用的抽象函数,使得类成为抽象类 (2)将构造函数定义为private. 为什么要这样做? 一些工具类,没有被实例化的必要.

  10. java基础之toString的使用方法

    toString方法,其返回值类型为String类型,用于返回表示对象值的字符串,返回类名和它的引用地址(散列码 hashCode)toString方法是Object类中的一个实例方法,所有的java ...