ural 1207 Median on the Plane
极角排序
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 30000
using namespace std; struct point
{
double x,y;
int num;
}p[maxn];
point pp;
double cross(const point &a,const point &b,const point &c)
{
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
bool cmp(const point &a,const point &b)
{
if(cross(p[],a,b)>) return ;
else return ;
}
int main()
{
int n;
int k=;
scanf("%d",&n);
for(int i=; i<n; i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
p[i].num=i+;
if(p[i].y<p[k].y||(p[k].y==p[i].y&&p[i].x<p[k].x)) k=i;
}
swap(p[],p[k]);
sort(p+,p+n,cmp);
printf("%d %d\n",p[].num,p[n/].num);
return ;
}
ural 1207 Median on the Plane的更多相关文章
- ural 1306. Sequence Median
1306. Sequence Median Time limit: 1.0 secondMemory limit: 1 MBLanguage limit: C, C++, Pascal Given a ...
- URAL 1306 Sequence Median(优先队列)
题意:求一串数字里的中位数.内存为1M.每个数范围是0到2的31次方-1. 思路:很容易想到把数字全部读入,然后排序,但是会超内存.用计数排序但是数又太大.由于我们只需要第n/2.n/2+1大(n为偶 ...
- URAL 1306 - Sequence Median 小内存求中位数
[题意]给出n(1~250000)个数(int以内),求中位数 [题解]一开始直接sort,发现MLE,才发现内存限制1024k,那么就不能开int[250000]的数组了(4*250000=1,00 ...
- Applying vector median filter on RGB image based on matlab
前言: 最近想看看矢量中值滤波(Vector median filter, VMF)在GRB图像上的滤波效果,意外的是找了一大圈却发现网上没有现成的code,所以通过matab亲自实现了一个,需要学习 ...
- ural 1246. Tethered Dog
1246. Tethered Dog Time limit: 1.0 secondMemory limit: 64 MB A dog is tethered to a pole with a rope ...
- Ural 2036. Intersect Until You're Sick of It 计算几何
2036. Intersect Until You're Sick of It 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2036 ...
- Ural State University Internal Contest October'2000 Junior Session
POJ 上的一套水题,哈哈~~~,最后一题很恶心,不想写了~~~ Rope Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7 ...
- URAL 2036 Intersect Until You're Sick of It 形成点的个数 next_permutation()函数
A - Intersect Until You're Sick of It Time Limit:500MS Memory Limit:65536KB 64bit IO Format: ...
- No.004:Median of Two Sorted Arrays
问题: There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the ...
随机推荐
- 【建模】UML类关系分析
一.UML类关系分析 1.关联(asociation) 一般是一方拥有另一方对象的指针.箭头的方向是访问方向. 2.聚合(Aggregation)和组合(Composition) 聚合和关联一般不做区 ...
- WebView redirect https to http
最新项目大改版,刚好对相关sdk版本做了下升级,target也从19升级到21. 意外发现原先在WebView中加载的网页中的图片全都变得一片白,连默认图片都不给显示. 经过一番测试才发现是由于tar ...
- Spark RDD API具体解释(一) Map和Reduce
本文由cmd markdown编辑.原始链接:https://www.zybuluo.com/jewes/note/35032 RDD是什么? RDD是Spark中的抽象数据结构类型,不论什么数据在S ...
- NYOJ528 找球号(三)位运算
找球号(三) 时间限制:2000 ms | 内存限制:3000 KB 难度:2 描述 xiaod现在正在某个球场负责网球的管理工作.为了方便管理,他把每个球都编了号,且每个编号的球的总个数都是 ...
- 反编译 APKTool 逆向助手
最佳实践--Android逆向助手 1.点击"反编译apk,完成后res下的所有资源就都可以正常使用了,相当于apktool的功能------目前已失效,但是直接用rar解压是可以的!2.点 ...
- CSS3 之动画及兼容性调优
由于CSS3动画对低版本的浏览器的支持效果并不是很好,特别是IE9及以下版本,更是无法支持. 所以有时候一些简单的动画效果,还只是用js代码来实现,但是效率偏低,而且效果有些偏生硬,不够顺滑. 毕竟用 ...
- svn和git比较
svn有哪些优点和缺点? git有哪些优点和缺点? git最突然的优点就是gitflow,开发新的功能都是开一个新分支feature,完成开发新特性,合并到develop分支:提交测试也是新增一个分支 ...
- linux的exec命令
linux的exec命令可以多进程执行,如果在浏览器访问使用http协议,会存在内存溢出和执行时间问题.
- Error: theForm.submit is not a function !!
theForm.submit is not a function 调试了半天,才发现范了低级错误. 页面中有一个按钮ID 是 submit 而引发的错误. 引出的问题是页面上的元素命名范围不能是 wi ...
- 如何使用CSS Sprites技术进行图片合并
http://jingyan.baidu.com/article/066074d6757654c3c21cb02d.html