Smallest Bounding Rectangle Given the Cartesian coordinates of n(>0)2-dimensional points, write a program that computes the area of their smallest bounding rectangle (smallest rectangle containing all the given points). Input The input le may contain…
题意:给你一些点,找出两个可以包含所有点的矩形,一个保证矩形面积最小,一个保证矩形周长最小,输出两个最小值 题解:首先根据所有点求一个凸包,再在这个凸包上枚举每条边,作为矩形的一条边(这样可以保证最小) 接着根据旋转卡壳的思想求出另外三条边,这样枚举判断就好 求另三条边时首先方向是确定了的,找点就是旋转卡壳,思想就是:枚举的任意两条边a与b,a的另三条边与b的另三条边都不会再a与b之间,并且b对应边一定最a对应边的      后面(注意是循环的边)那么就是说,我们可以使用类似双指针方式维护,但是…
https://vjudge.net/problem/UVA-12307 求覆盖所有点的最小矩形面积.周长 相当于求凸包的最小面积外接矩形.最小周长外接矩形 结论: 这个矩形一定有一条边和凸包上一条边重合 证明去看https://wenku.baidu.com/view/f11d0836ee06eff9aef807d9.html 枚举一条边,用旋转卡壳求其他三边 假设现在正枚举到A点,对应紫色边, 显然,紫色边的对边一定 过A点的对踵点且与紫色边平行 那么矩形的高|BH|=AE.AB的叉积/ |…
题意: 给出若干个栋楼俯视图的坐标和面积,求从俯视图的南面(可以视为正视图)看过去到底能看到多少栋楼. 输入第一个n说明有n栋楼,然后输入5个实数(注意是实数),分别是楼的左下角坐标(x,y), 然后楼的x方向的宽度,y方向的深度,还有楼的高度. 按横坐标,横坐标同样按纵坐标排序输出所有能看到的楼. 分析: 先记录一个一开始就想错的做法: 以为只要把x 和 width放大到到足够大(例如10000倍,倍数越高精度越高),然后排序填充一下数轴就可以,就可以解决x坐标是小数的问题.但这样打了一下,发…
http://acm.hdu.edu.cn/showproblem.php?pid=5124 Problem Description John has several lines. The lines are covered on the X axis. Let A is a point which is covered by the most lines. John wants to know how many lines cover A.   Input The first line con…
判断矩形能包围点集的最小面积:凸包 #include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <string> #include <sstream> #include <algorithm> #define Max 2147483647 #define INF 0x7…
题目传送门 题意:找一条直线,使得其余的点都在直线的同一侧,而且使得到直线的平均距离最短. 分析:训练指南P274,先求凸包,如果每条边都算一边的话,是O (n ^ 2),然而根据公式知直线一般式为Ax + By + C = 0.点(x0, y0)到直线的距离为:fabs(Ax0+By0+C)/sqrt(A*A+B*B). 所以只要先求出x的和以及y的和,能在O (1)计算所有距离和. 两点式直线方程p1 (x1, y1),p2 (x2, y2)转换成一般式直线方程:A = y1 - y2, B…
Problem You have been invited to the popular TV show "Would you like to be a millionaire?". Of course you would! The rules of the show are simple: Before the game starts, the host spins a wheel of fortune to determine P, the probability of winni…
bitch bitch bitch... TLE,WA一大坨,我是在拿生命来JUDGE啊.. 不得不说,UVA上的数据根本不是随机的,而是有预谋的. for(int i=2;i<n;i++){ while(stop>1&&cross(p[i],p[st[stop-1]],p[st[stop-2]])>=0) stop--;   //这个我本来是cross(p[i],p[st[stop-1]],p[st[stop-2]])>0 st[stop++]=i; } 因为没加…
题意:给出两点,求经过这两点的正n边形的最小面积 题解:这两点一定是最长的弦,我们设正多边形中点c,找到c到每个点的距离(都相同) 我们知道那个等腰三角形的底与每个角度就使用余弦定理 #include<set> #include<map> #include<queue> #include<stack> #include<cmath> #include<vector> #include<string> #include<…