上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 50 下一页
摘要: 在C语言的math.h或C++中的cmath中有两个求反正切的函数atan(double x)与atan2(double y,double x) 他们返回的值是弧度 要转化为角度再自己处理下。 前者接受的是一个正切值(直线的斜率)得到夹角,但是由于正切的规律性本可以有两个角度的但它却只返回一个,因为 阅读全文
posted @ 2016-04-15 11:04 gongpixin 阅读(559) 评论(0) 推荐(0) 编辑
摘要: 1001.没推到题解那么细,枚举一下也可以。用通分可以避免小数精度问题。 #include<iostream> #include<stdio.h> using namespace std; int main(){ int T; int n,m; int a,b,c; int i,j; bool fl 阅读全文
posted @ 2016-04-10 17:20 gongpixin 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 1.素数 c.普通法 /* 普通法求素数 */ #include<iostream> #include<stdio.h> #include<math.h> using namespace std; bool prime(int m) { int i,k; bool flag=true; k=sqrt 阅读全文
posted @ 2016-04-08 19:46 gongpixin 阅读(311) 评论(0) 推荐(0) 编辑
摘要: POJ - 1330 Nearest Common Ancestors(dfs+ST在线算法|LCA倍增法) d.输入树中的节点数N,输入树中的N-1条边。最后输入2个点,输出它们的最近公共祖先。 s.裸的最近公共祖先。 c.dfs+ST在线算法: /* LCA(POJ 1330) 在线算法 DFS 阅读全文
posted @ 2016-04-08 10:53 gongpixin 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 二分图的相关概念 二分图:二分图又称二部图,是图论中的一种特殊模型。设G=(V,E)是一个无向图,如果点集V可以分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个点i和j分别属于这两个不同的点集(iin A, j in B), 则称图G是二分图 1.匹配:给定一个二分图,在G 阅读全文
posted @ 2016-04-08 10:04 gongpixin 阅读(643) 评论(0) 推荐(0) 编辑
摘要: 1.01背包 hdu 2602 Bone Collector(01背包) 题意:给出包裹的大小v,然后给出n块骨头的价值value和体积volume,求出一路下来包裹可以携带骨头最大价值 思路:01背包 1.二维数组(不常用 /* 01背包 二维数组 */ #include<iostream> #i 阅读全文
posted @ 2016-04-08 09:17 gongpixin 阅读(248) 评论(0) 推荐(0) 编辑
摘要: c.单点更新 /* 线段树 单点更新 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define L(root) ((root)<<1) #define R(root) (((root 阅读全文
posted @ 2016-04-07 20:35 gongpixin 阅读(247) 评论(0) 推荐(0) 编辑
摘要: c. /* 树状数组 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int n,c[50005]; int lowbit(int i){ return i&-i; } void upda 阅读全文
posted @ 2016-04-07 20:31 gongpixin 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 1.最大流 ps:直接以题目来看模板的使用 POJ - 1459 Power Network(最大流)(模板) d.看了好久,囧。 n个节点,np个源点,nc个汇点,m条边(对应代码中即节点u 到节点v 的最大流量为z) 求所有汇点的最大流。 s.多个源点,多个汇点的最大流。 建立一个超级源点、一个 阅读全文
posted @ 2016-04-07 20:13 gongpixin 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 多源最短路径 c.floyd /* 多源最短路径 floyd */ #include<iostream> #include<stdio.h> using namespace std; #define MAXN 1010 #define typec int #define INF 0x3f3f3f3f 阅读全文
posted @ 2016-04-07 20:06 gongpixin 阅读(216) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 50 下一页