1、1三角形面积计算 .1字典树模板 .2求线段所在直线 .5求外接圆 .5求内接圆 .6判断点是否在直线上 .8简单多边形面积计算公式 .8stein 算法求最大共约数 .9最长递增子序列模板 o(nlogn 算法实现) .9判断图中同一直线的点的最大数量 .10公因数和公倍数 .12已知先序中序求后序 .12深度优先搜索模板 .13匈牙利算法 二部图匹配 BFS 实现 .15带输出路径的 prime 算法 .17prime 模板 .18kruskal 模板 .19dijsktra.22并查集模板 .23高精度模板 .24三角形面积计算/已知三条边和外接圆半径,公式为 s = a*b*c/(4*
2、R)double GetArea(double a, double b, double c, double R)return a*b*c/4/R;/已知三条边和内接圆半径,公式为 s = prdouble GetArea(double a, double b, double c, double r)return r*(a+b+c)/2;/已知三角形三条边,求面积double GetArea(doule a, double b, double c)double p = (a+b+c)/2;return sqrt(p*(p-a)*(p-b)*(p-c);2/已知道三角形三个顶点的坐标struct
3、Pointdouble x, y;Point(double a = 0, double b = 0)x = a; y = b;double GetArea(Point p1, Point p2, Point p3)double t = -p2.x*p1.y+p3.x*p1.y+p1.x*p2.y-p3.x*p2.y-p1.x*p3.y+p2.x*p3.y;if(t #include #include #define BASE_LETTER a#define MAX_TREE 35000#define MAX_BRANCH 26structint nextMAX_BRANCH; /记录分支的位置
4、int cMAX_BRANCH; /查看分支的个数int flag; /是否存在以该结点为终止结点的东东,可以更改为任意的属性 trieMAX_TREE;int now;void init()now = 0;memset(3now +;int add ()memset(return now+;int insert( char *str)int pre = 0, addr;while( *str != 0 )addr = *str - BASE_LETTER;if( !triepre.nextaddr )triepre.nextaddr = add();triepre.caddr+;pre =
5、triepre.nextaddr;str +;triepre.flag = 1;return pre;int search( char *str )int pre = 0, addr;while( *str != 0 )addr = *str - BASE_LETTER;if ( !triepre.nextaddr )return 0;pre = triepre.nextaddr;str +;if( !triepre.flag )return 0;4return pre;pku2001 题,源代码:void check( char *str )int pre = 0, addr;while(*
6、str != 0)addr = *str - BASE_LETTER;if( triepre.caddr = 1)printf(“%cn“, *str);return;printf(“%c“, *str);pre = triepre.nextaddr;str +;printf(“n“);char input100125;int main()int i = 0,j;init();while(scanf(“%s“, inputi) != EOF)getchar();insert(inputi);i+;for(j = 0; j p1.x int main()int count,i,n,left,mi
7、d,right,Blen=0,num;scanf(“%d“, /case 的个数while(count-)scanf(“%d“, /每组成员的数量Blen = 0;for(i=1;i#include #include using namespace std;#define MAX 1010 /最大点的个数struct pointint x,y;numMAX;int usedMAXMAX*2; /条件中点的左边不会大于 1000,just equal MAXint countNMAXMAX*2;#define abs(a) (a0?a:(-a) int GCD(int x, int y)int temp;if(x y)