摘要: #include using namespace std;//一般方法int pow1(int a, int b){ int t = a; b--; while(b--) a *= t; return a;}//普通快速幂int pow2(int a,int... 阅读全文
posted @ 2015-01-02 21:47 Popco 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 向量叉积有甚多应用,包括求三角形面积,判断线段相交,求多边形面积,判断多边形凹凸性,而且不需要推大量公式,误差较小,非常实用,下面是代码 //向量叉积的应用#include #define EPS 1e-10using namespace std;struct point{ doubl... 阅读全文
posted @ 2015-01-02 12:40 Popco 阅读(411) 评论(0) 推荐(1) 编辑
摘要: 以前只是研究某两个进制A,B之间的转化,现在推广到任意进制。 其中十进制转为B进制:除B取余,倒序排列 目前的缺点是不能算小数和负数。 #include using namespace std;int toTen(const string & old, const int base){ ... 阅读全文
posted @ 2015-01-02 09:59 Popco 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 最近打算研究一下基础的算法,就先从二分开始做吧,三种方法 #include using namespace std;const int MAXN = 1024;int num[MAXN];//生成测试数据void init(){ for(int i = 0; i > 1; i... 阅读全文
posted @ 2015-01-02 08:52 Popco 阅读(212) 评论(0) 推荐(0) 编辑