基础算法
文章平均质量分 63
Alex_Dong
这个作者很懒,什么都没留下…
展开
-
hdu 4004题解
-hdu- 4004题目大意:在宽度为L的河上给定n个落脚点,位置分别给出,通过最多m次跳跃来过河,问我们其中跳跃距离最远的那个值是多少。 题目解析:设ans是相邻落脚点之间的最大距离,所以结果值的范围是【ans, L】。利用二分法缩小这个范围。mid = (left+right)/2;跳跃能力是mid值,如果跳跃次数solve(mid) 代码如下: #in原创 2014-02-02 16:26:13 · 593 阅读 · 0 评论 -
自己创建map结构体 sort + cmp
#include #include #include using namespace std;struct Point{ int x, y;};struct Map{ Point p; float f;};bool cmp(Map x, Map y){ return x.f < y.f;}int main(){ vector vec; for原创 2014-12-16 22:43:09 · 771 阅读 · 0 评论 -
平行线判断函数+求平行线之间的距离
// 得到直线的tan斜率double GetTanOfLine( LINE line ){ double x_dis = line.pt0.x - line.pt1.x; if ( x_dis == 0.0 ) return 10e9; return (line.pt0.y - line.pt1.y) / x_dis;}// 得到两条平行线之间的距离dou原创 2015-03-25 14:11:26 · 6231 阅读 · 0 评论 -
提取某种颜色的像素点
// 洗刷掉某种颜色void WashOffTheColor( IplImage* src ){ if ( src == NULL ) { return ; } const int width = src->width; const int height = src->heigh原创 2015-03-26 20:58:03 · 1444 阅读 · 0 评论 -
利用opencv的hog+svm实现细胞识别分类器
利用opencv的hog+svm实现细胞识别分类器 图像处理中的细胞识别和人脸识别可以这样来类比,图像中的一张张人脸就是一个个细胞。模式识别的关键在于样本库的选取,识别率也只能在和样本库比较接近的环境下才能保证。主要工作是三部分一是特征提取,二是样本库的训练train,三是目标检测detect。一.特征提取特征提取采用的是HOG特征即HOG描述子,该特征在行人检测中效果非常好。原创 2015-03-07 22:55:21 · 4133 阅读 · 4 评论 -
利用opencv实现截图函数
// 矩形截图bool Screenshot( IplImage* src, IplImage* dst, CvRect rect ){ cvSetImageROI( src, rect ); cvCopy( src, dst, 0 ); cvResetImageROI( src ); return 0;}// 安全重置矩形大小void SafeResetSizeOfRect(原创 2015-03-08 12:05:39 · 7804 阅读 · 0 评论 -
自己写的重命名函数(前缀+编号)
// 重命名图像// src: 原图像// saveFolderPath: 将保持的文件夹路径// prefix: 名称的前缀// numName: 名称编号bool RenameImage(IplImage* src, CString saveFolderPath, CString prefix, int& numName){CString name, str;name = prefix;str原创 2015-03-07 16:53:19 · 1183 阅读 · 0 评论 -
批处理文件夹里的图片
bool GetPicDirSetInFolder(CString strFindPath, std::vector &vecPathSet){ WIN32_FIND_DATA wfd; HANDLE hf = FindFirstFileA(strFindPath, &wfd); if (INVALID_HANDLE_VALUE != hf) { vecPathSe原创 2015-03-25 22:53:15 · 839 阅读 · 0 评论 -
opencv 遍历rgb图
void Traverse( IplImage* src ){ if ( src == NULL ) { return ; } const int width = src->width; const int height = src->height; const int widthSte原创 2015-03-24 12:08:27 · 1665 阅读 · 0 评论 -
opencv找轮廓线并绘制轮廓线
IplImage* bin = cvCloneImage( gray );cvAdaptiveThreshold( gray, bin, 255, CV_ADAPTIVE_THRESH_MEAN_C, 0, 101, 5 );cvDilate( bin, bin, 0, 1 );CvMemStorage* storage = cvCreateMemStorage(0);CvContou原创 2015-03-25 17:16:39 · 3191 阅读 · 0 评论 -
hdu 4715 素数打表
先利用筛法完成素数打表再从小到大判断即可#include#include#include#include#include#includeusing namespace std; const int Max = 1e6 + 50;int n;int isPrime[Max];int tblPrime[Max];int lenPrimes;void initTbl原创 2014-08-16 16:39:04 · 535 阅读 · 0 评论 -
利用筛法求素数表
利用筛法求素数表const int Max = 1e6 + 50;int isPrime[Max]; //素数判断结果表int tblPrime[Max]; //所求得的素数表int lenPrimes; //所求得的素数表的长度(个数)void initTblOfPrime(){ memset(isPrime, 1, sizeof(isPrime)); isPrime[0]原创 2014-08-16 16:43:32 · 675 阅读 · 0 评论 -
hdu 1232 并查集
并查集,一并combine一查find原创 2014-02-12 23:00:39 · 428 阅读 · 0 评论 -
hdu 1496
hash#includeusing namespace std;int a, b, c, d;int x1, x2, x3, x4;int f1[1000005];int f2[1000005];int main(){ while(cin >> a >> b >> c >> d) { if( a > 0 && b > 0 && c > 0 && d > 0){原创 2014-06-02 22:47:06 · 627 阅读 · 0 评论 -
hdu 1800字典树
简单的字典树实现#include#includeusing namespace std;int N, n, Max;string str;char ch;struct node{ node* son[10]; int tag; int count; node() { tag = 1; count = 0; for(int i = 0; i < 10;原创 2014-06-08 00:38:22 · 570 阅读 · 0 评论 -
hdu 4109 dfs+剪枝优化
求最久时间即在无环有向图里求最远路径dfs+剪枝优化从0节点(自己增加的)出发,0到1~n个节点之间的距离为1,mt[i]表示从0点到第i个节点目前所得的最长路径#include#include#include#include#include#includeusing namespace std;const int maxn = 1005;int m原创 2014-07-24 17:38:18 · 774 阅读 · 0 评论 -
hdu 4704 费马小定理+快速幂
题意就是:做整数拆分,答案是2^(n-1)由费马小定理可得:2^n % p = 2^[ n % (p-1) ] % p当n为超大数时,对其每个数位的数分开来加权计算当n为整型类型时,用快速幂的方法求解#include#include#include#include#includeusing namespace std;const int Mod = 1e9+7;原创 2014-07-28 11:33:42 · 579 阅读 · 0 评论 -
hdu 4706
#include#include#include#include#include#includeusing namespace std;int main(){ printf("a e\nbdf\nc g\n"); printf("h n\ni mo\njl p\nk q\n"); printf("r z\ns ya\nt x b\nuw c\原创 2014-08-13 14:41:58 · 526 阅读 · 0 评论 -
hdu 4712 随机数方法求解
#include#include#include#include#include#include#includeusing namespace std;const int Max = 100050;char str[Max][10];int mark[16][16];int num[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2原创 2014-08-13 14:39:05 · 605 阅读 · 0 评论 -
hdu 4709
求三角形的面积利用向量点乘得到三角形的面积三个for循环嵌套即可#include#include#include#includeusing namespace std;const double INF = 1e9+50;double x[1000];double y[1000];double area(int i, int j, int k){ do原创 2014-08-13 14:33:56 · 563 阅读 · 0 评论 -
hdu 4707 bfs
bfs基础算法水题#include#include#include#include#include#include#includeusing namespace std;const int Max = 1e5+50;int dist[Max];vector tree[Max];int N, D, T;void init(){ for(int i = 0;原创 2014-08-13 14:36:18 · 514 阅读 · 0 评论 -
静态编译opencv
1.包含目录2.库目录D:\\opencv\\build\\x86\\vc11\\staticlib3.运行库配置属性->C/C++->代码生成->运行库多线程(/MTd),Debug下选择多线程(/MT),Release下选择4.pragram comment lib库文件代码如下:#include... // 这几个依赖库文件必须要添加// 因为原创 2015-03-22 11:58:04 · 661 阅读 · 0 评论