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[] ...
随机推荐
- [STemWin教程入门篇]第二期:emWin5.xx的详细移植步骤
转自:http://bbs.armfly.com/read.php?tid=1545 重要说明:(0)由于这个移植教程是去年过年的时候做的,用的是5.16,这就不再做个5.20的移植了,方法是一样的. ...
- IDEA 报错记录
IDEA 报错记录 Process finished with exit code 0 这种主要是配了默认的 Tomcat ,然后又配置了外部的 Tomcat.解决办法,注释掉默认的: <dep ...
- EOJ 1127. 多边形面积(计算几何)
题目链接:1127. 多边形面积(计算几何) 题意 按逆时针顺序给出 \(n\) 个点的坐标,求这些点围成的多边形的面积. 思路 选择多边形上的一个点,然后每次枚举之后的两个点,计算叉积,注意要保留符 ...
- jmeter压测、操作数据库、分布式、 linux下运行的简单介绍
一.jmeter压测 1.如何压测 常规性能压测:10-15分钟 稳定性测试:一周.2天等 如果想要压测10分钟,勾选永远,勾选调度器,填写600秒.也可以使用固定启动时间. 2.tps.响应时间 ( ...
- 《linux 内核全然剖析》sched.c sched.h 代码分析笔记
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011368821/article/details/25129835 sched.c sched.h ...
- 写第一个 swift,iOS 8.0程序
class ViewController: UIViewController { @IBAction func btn_click(sender : AnyObject) { println(&quo ...
- docker报错: x509: certificate has expired or is not yet valid
环境:最小化安装centos7 问题:docker 启动没问题,但是查询 镜像时报错 Error response from daemon: Get https://index.docker.io/v ...
- 【牛客网-剑指offer】斐波拉契数列
题目: 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0).n<=39 知识点: 一列数:从1开始,前两项为1,从第三项开始每一项等于前两项之和 ...
- 2019-9-2-win10-uwp-Markdown
title author date CreateTime categories win10 uwp Markdown lindexi 2019-09-02 12:57:38 +0800 2018-2- ...
- tcp - 传输控制协议 (TCP)
总缆 SYNOPSIS #include <sys/socket.h> #include <netinet/in.h> tcp_socket = socket(PF_INET, ...