摘要:
/** 利用叉乘判断多边形是凸的,还是凹的* auther:Try86 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;struct point { int x; int y;}A, B, C, tA, tB;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);}int main() { int n; while (scanf 阅读全文
posted @ 2012-04-22 21:37
Try86
阅读(406)
评论(0)
推荐(0)
摘要:
/** 题意:判断点在多边形内* 判点在任意多边形内,顶点按顺时针或逆时针给出*/#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 100;const int offset = 1000; //offset为多边形坐标上限const double eps = 1e-8;struct point { double x; double y;}p[N], p1, p2;bool isZero(do 阅读全文
posted @ 2012-04-22 20:44
Try86
阅读(1912)
评论(0)
推荐(0)
摘要:
View Code /** 利用叉乘判断拐向 * auther:Try86*/#include <cstdio>#include <iostream>using namespace std;char str[1000];struct point { int x; int y;}A, B, C;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);}int main() { int n; while (scanf("%d", 阅读全文
posted @ 2012-04-22 11:39
Try86
阅读(186)
评论(0)
推荐(0)
摘要:
View Code /*摘自:ACM百科网 巴什博奕(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。显然,如果n=m+1,那么由于一次最多只能取m个,所以,无论先取者拿走多少个,后取者都能够一次拿走剩余的物品,后者取胜。因此我们发现了如何取胜的法则:如果n=(m+1)r+s,(r为任意自然数,s≤m),那么先取者要拿走s个物品,如果后取者拿走k(≤m)个,那么先取者再拿走m+1-k个,结果剩下(m+1)(r-1)个,以后保持这样的取法,那么先取者肯定获胜。总之,要保持给对手留下(m+1)的倍数,就能最后获胜。这个游戏还可以有 阅读全文
posted @ 2012-04-22 11:18
Try86
阅读(141)
评论(0)
推荐(0)
摘要:
View Code /** 题目要求:判断点是否在三角形内* 可利用叉乘判断拐向来解决 * auther:Try86*/#include <cstdio>#include <iostream>using namespace std;struct point { int x; int y;}A, B, C, D;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);}bool inTrangle() { if (crossProd(D, ... 阅读全文
posted @ 2012-04-22 10:54
Try86
阅读(146)
评论(0)
推荐(0)
摘要:
View Code /** 题目要求:判断点是否在凸多边形内 * 方法:利用叉乘判断拐向来求解 * auther:Try86 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 100;struct point { double x; double y;}p[N], doTa;double crossProd(point A, point B, point C){ return (B.x-A.x)*(C.y-A.y) - (B.y- 阅读全文
posted @ 2012-04-22 10:36
Try86
阅读(196)
评论(0)
推荐(0)
摘要:
View Code /** 题目所求:在直线上找一点P,使其与其它(A,B)两点组成的距离最短 * 点A跟点B与直线的位置情况四种:* 1.两点在直线的同侧(两点都不在直线上) * 2.两点在直线的异侧(两点都不在直线上) * 3.其中一点在直线上* 4.两点都在直线上* auther:Try86 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;struct point {//点结构 double x; doub 阅读全文
posted @ 2012-04-22 10:03
Try86
阅读(194)
评论(0)
推荐(0)
摘要:
View Code /** 题目要求:求一组线段的总的交点数* 判断两线段相交:1快速排斥,2跨立实验 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 100;struct point {//点结构 double x; double y;};struct segment {//线段结构 point s; point e;}seg[N];double crossProd(point A, point B, point C) { . 阅读全文
posted @ 2012-04-22 08:36
Try86
阅读(192)
评论(0)
推荐(0)