随笔分类 - 几何
hdu 4617 Weapon
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4617三维几何简单题 多谢高尚博学长留下的模板代码:#include #include #include #include #include using namespace std;typedef long long ll;typedef pairppd;const double PI = acos(-1.);const int MAXL = (1 << 18)+100;const double eps = (1e-9);const int N=50;struct point3{double x,
阅读全文
hdu 4606 Occupy Cities
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4606两点之间如果有线段相隔的话,他们的最短路就需要经过线段的端点把所有线段的端点也加入点数组中,求任意两个点的距离(可达的话,没有其他线段阻挡)然后对所有的点进行floyd 可以求出任意两点的最短路然后二分所需容量 根据容量和要求的顺序进行建图,求最小覆盖路径(匈牙利算法)代码:#include#include#include#include#include#include#include#include#include#include#include#include#include#include#inc
阅读全文
zoj 2318 Get Out!
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1318推荐解题报告:http://www.cppblog.com/Yuan/archive/2010/05/02/114163.html自己对几何题目是一窍不通呀,尤其是精度问题 狂晕,这题也是看了别人的解析思路,把人所在位置移动到原点,其他点也移动相应位置,然后把人的船当成点,这样的话其他岛屿的半径统一加上船的半径就可以了然后相交的岛屿连线,看能不能有一个多边形把原点包起来判别方法,根据点积求角度,根据叉积求正负,然后看有没有负环更新时dist[i][j]>dist[
阅读全文
1065. Frontier
摘要:http://acm.timus.ru/problem.aspx?space=1&num=1065分两种情况1,M==0 的情况 这时枚举任意三个点(不共线) 算长度 取最短2,M!=0 的情况 这时枚举任意点到其它每个点的距离 比如说从i到j 距离 如果所有的M个点都在从i到j向量的右面 则距离可以直接求出 否则暂时为无穷大 然后用 floyd求最短路 最后求最小的环形路代码:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<ma
阅读全文
hdu 4291 A Short problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4291找循环节 + 矩阵连乘代码:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <vector>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:1024000000,1024000000")using name
阅读全文
poj 3277 City Horizon
摘要:http://poj.org/problem?id=3277经典的矩形面积并 对y离散后 建树 用拆点后的以x为顺序 依次更新代码:#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>#define LL long longusing namespace
阅读全文
poj 1151 Atlantis
摘要:http://poj.org/problem?id=1151几何面积并 离散化线段树 #include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<queue>#include<cstring>#include<set>#include<cmath>#include<algorithm>#define LL long longusing namespace std;const int N=105;st
阅读全文
poj 1584 A Round Peg in a Ground Hole
摘要:http://poj.org/problem?id=1584题意 给你个多边形和一个钉子,让你判断是否 钉子可以放里面注意 1,多边形所给的顺序 可能是逆时针也可能时顺时针 2 ,钉子可能在多边形外面 3 ,钉子可能在多边形上 4 ,先给半径后给圆的坐标#include<iostream>#include<cmath>#include<string>#include<algorithm>#include<queue>#include<cstring>#include<cstdio>using namespace
阅读全文
poj 1408 Fishnet
摘要:本题数据量不大 直接求解先求出所有的交点,再枚举所有四边形的面积取最大#include<iostream>#include<cmath>#include<string>#include<algorithm>#include<queue>#include<map>#include<set>#include<cstring>#include<cstdio>using namespace std;const double K=1e-8;const int N=35;struct node{ d
阅读全文
poj 2187 Beauty Contest
摘要:http://poj.org/problem?id=2187求任意两点的最远距离平方,枚举所以的点肯定超时。最远两点肯定是凸包上的两点,所以先求凸包,再对凸包上的点两两枚举,求最大平方值#include<iostream>#include<cmath>#include<string>#include<algorithm>#include<queue>#include<cstring>#include<cstdio>using namespace std;const double PI=acos(-1);cons
阅读全文
poj 1113 Wall
摘要:http://poj.org/problem?id=1113题目大意国王给自己的城堡建围墙,围墙要和城堡保持一定距离L凸包,保持一定的距离只不过多了一个圆弧长度而已(PI*2*L)因为所有拐点处的圆弧加在一起是一个圆#include<iostream>#include<cmath>#include<string>#include<algorithm>#include<queue>#include<cstring>#include<cstdio>using namespace std;const double P
阅读全文
poj 1265 Area
摘要:http://poj.org/problem?id=1265pick定理对于方格点形成多边形面积=(内点)+(边上点/2)-1线段边上点数为(两点横坐标距离,两点纵坐标距离)的最大公约数 再加一对于本题来说 再加一的话 到最后还得剪掉 因为会重复计算 所以直接不加一就可以面积的求法 就是把多边形分割成多个三角形 需要自己动手画画#include<iostream>#include<cmath>#include<string>#include<algorithm>#include<cstring>#include<cstdio&g
阅读全文
sdut 2401 最大矩阵面积
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2401#include <iostream>#include <cstdio>#include <algorithm>using namespace std;const int N=1010;struct node{ int x,y;}mem[N];bool cmp(node a,node b){ if(a.x==b.x) return a.y<b.y; return a.x<b.x;}bool
阅读全文
浙公网安备 33010602011771号