上一页 1 2 3 4 5 6 7 8 9 10 ··· 14 下一页
  2012年4月23日
摘要: /** 题目要求:求面积最大的那个面的编号* 方法:分别求每个面的面积,并比较最大的面积 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 55;struct point { int x; int y;}p[N], sp[N];double crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A 阅读全文
posted @ 2012-04-23 21:46 Try86 阅读(222) 评论(0) 推荐(0)
摘要: /* 凸包+最小圆覆盖 枚举任意3点找其最小覆盖圆(当为钝角三角形时不是外接圆,而是以其最长边为直径的圆)。 当为外接圆时,半径公式为r=abc/4s;(推导为如下: 由正弦定理,a/sinA=b/sinB=c/sinC=2R,得sinA=a/(2R), 又三角形面积公式S=(bcsinA)/2,所以S=(abc)/(4R),故R=(abc)/(4S).*/#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const 阅读全文
posted @ 2012-04-23 21:01 Try86 阅读(1247) 评论(0) 推荐(0)
摘要: /** 题目要求:求凸包的周长 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 105;const double eps = 1e-8;struct point { int x; int y;}p[N], stack[N];bool isZero(double x) { return (x > 0 ? x : -x) < eps;}double dis(point A, p 阅读全文
posted @ 2012-04-23 18:46 Try86 阅读(884) 评论(0) 推荐(0)
  2012年4月22日
摘要: /** 利用叉乘判断多边形是凸的,还是凹的* 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 阅读(147) 评论(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 阅读(197) 评论(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 阅读(196) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 14 下一页