上一页 1 2 3 4 5 6 7 8 9 ··· 99 下一页

2012年9月22日

HDU 4407 sum 容斥原理

摘要: 算法:利用数据1...N的性质,求与P的互质的个数,位运算,容斥定理。。#include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#include<vector>#include<string>#include<math.h>#include<map>#include<set>#include<algorithm>using namespace std;struct info{ int s,e 阅读全文

posted @ 2012-09-22 21:07 more think, more gains 阅读(327) 评论(0) 推荐(0) 编辑

2012年9月17日

poj 2750 Potted Flower

摘要: 看了解题报告才会做....算法:线段树 + 动态规划线段树需要保存的信息:struct node{ int l,r; //左右端点 long long sum, max, min;//区间和,最大子序列和,最小子序列和 long long lmax, lmin, rmax, rmin;//左边连续最大和,左边连续子序列最小和,右边连续最大子序列和,右边连续最小子序列和 }seg[MAXN*4];自己想时遇到的主要问题是,如何处理最大子序列和是首尾相连的这一序列。。。不会处理这种问题。。。看了别人解题报告才知道,只要保留一个最小子序列和就可以了,然后总和减去这个最小子序列和。。如果1-N这个.. 阅读全文

posted @ 2012-09-17 19:31 more think, more gains 阅读(196) 评论(0) 推荐(0) 编辑

2012年9月15日

Palindrome DP

摘要: 算法:最长上升子序列,求字符串的正序和逆序的最长上升子序列,N - dp[N][N]就是最少要添加的单词。View Code #include<iostream>#include<string>using namespace std;class Matrix{ public: int solve(int ); void input( ) { scanf("%s", pstr+1);} void reverse(int ); private: char pstr[5010]; char qstr[5010]; short int dp[... 阅读全文

posted @ 2012-09-15 10:41 more think, more gains 阅读(191) 评论(0) 推荐(0) 编辑

2012年9月10日

HDU 4323 bk树 编辑距离

摘要: 1. dp求编辑距离2. bk树找相差d的单词。View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#include<vector>#include<string>#include<math.h>#include<map>#include<set>#include<stack>#include<queue>#include<algorithm> 阅读全文

posted @ 2012-09-10 17:38 more think, more gains 阅读(1116) 评论(0) 推荐(0) 编辑

2012年9月8日

编辑距离

摘要: 编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。算法:动态规划代码:View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#include<vector>#include<string>#include<math.h>#include<ma 阅读全文

posted @ 2012-09-08 11:20 more think, more gains 阅读(229) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 99 下一页

导航