HCW 19 Team Round (ICPC format) H Houston, Are You There?(极角排序)
题目链接: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?(极角排序)的更多相关文章
- 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 ...
- 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 ...
- Educational Codeforces Round 1 C. Nearest vectors 极角排序
Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/ ...
- 2018 ICPC北京 H ac自动机
n=40的01串,求有多少m=40的01串中包含它,包含的定义是存在子串有至多一个字符不相同 600组n=15的数据 15组n=40的数据,所以我们只能支持n^5的算法. 陷入两个比较有意思的坑: 1 ...
- icpc 银川 H. Delivery Route SPFA优化
Problem Description Pony is the boss of a courier company. The company needs to deliver packages to ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #541 (Div. 2) D 并查集 + 拓扑排序
https://codeforces.com/contest/1131/problem/D 题意 给你一个n*m二维偏序表,代表x[i]和y[j]的大小关系,根据表构造大小分别为n,m的x[],y[] ...
随机推荐
- JavaBean详解
JavaBean详解 我们对JavaBean的理解可以从java和bean两个方面来理解,对于Java我们都很清楚,而bean在计算机中的含义为可重用组件.(ps:对Spring中的bean是不是有了 ...
- bootstrap Grid布局(网格布局)
基本网络结构 <div class="container"> <div class="row"> <div class=" ...
- camunda用户的一些简单操作
act_id_group:存放组信息act_id_membership:存放用户与组的相关信息act_id_user:存放用户act_id_info:存放用户个人信息act_id_tenant:存放租 ...
- HTML5网页如何让所有的浏览器都能识别语义元素标签样式
浏览器对语义元素的支持情况 如今HTML5愈来愈引发大家的关注了,但目前支持HTML5的浏览器还不是主流,特别是国内用户近50%以上仍旧使用IE6,由于支持HTML5的IE9不支持Xp系统安装,这样未 ...
- 马士兵对话京东T6阿里P7(薪水):月薪5万,他为何要离职?
马士兵大佬你知道吗? 你竟然不知道?你怎么可能不知道!你不知道是不可能的! 记得自己的第一行Java代码,你的Hello World是跟着谁学的吗?我的就是马士兵老师! 马士兵是唯一一个在当时讲课是让 ...
- linux性能查看调优
一 linux服务器性能查看1.1 cpu性能查看1.查看物理cpu个数:cat /proc/cpuinfo |grep "physical id"|sort|uniq|wc -l ...
- go strconv
strconv是golang用来做数据类型转换的一个库. 介绍下strconv最常用的两个方法, 没有解释语言那么自在可以str(int),int(string), 那还算简练. num, err : ...
- Android多线程:深入分析 Handler机制源码(二)
前言 在Android开发的多线程应用场景中,Handler机制十分常用 接下来,深入分析 Handler机制的源码,希望加深理解 目录 1. Handler 机制简介 定义一套 Android 消息 ...
- MS14-068利用
漏洞原理详情后续补上:kerberos 协议实现过程中的某些 bug,致使普通域用户可以任意伪造高权限 PAC,去请求 TGS 从而导致的权限提升,漏洞现在很少遇到了. 一.利用 需要拥有一个域账号的 ...
- 【学术篇】The Xuanku Inversion Magic学习笔记
退役之前写的 然后因为退役就咕咕咕了... 后来发现数学考试能用的到个鬼就发布出来了QwQ 主要是方便自己没登录的时候查阅... 显然子集什么的是没有学会的QwQ 所以学OI的话不要看本文!!!!!& ...