随笔分类 -  学习——ACM

摘要:Levenshtein Distance (LD, 来文史特距离)也叫edit distance(编辑距离),它用来表示2个字符串的相似度,LD定义为需要最少多少步基本操作才能让2个字符串相等,基本操作包含3个:插入, 删除, 替换;比如,kiteen和sitting之间的距离可以这么计算:1,kitten -- > sitten, 替换k为s;2,sitten -- > sittin, 替换e为i;3,sittin -- > sitting, 增加g;所以,其LD为3。设计状态d[m][n] = d(A[1..m], B[1..n]),易知:d[0][0] = 0;d[i] 阅读全文
posted @ 2012-08-01 15:29 E_star 阅读(274) 评论(0) 推荐(0) 编辑
摘要:差分约束:http://972169909-qq-com.iteye.com/blog/1185527KM算法:http://972169909-qq-com.iteye.com/blog/1184514最短路:http://972169909-qq-com.iteye.com/blog/1156071匹配:http://hi.baidu.com/_lt_zyc/item/0414aee9030341e7e1a5d4fe树状数组:http://hi.baidu.com/lilu03555/blog/item/4118f04429739580b3b7dc74.html矩阵:http://www. 阅读全文
posted @ 2012-07-21 21:10 E_star 阅读(273) 评论(0) 推荐(0) 编辑
摘要:摘自上海交大bbs:奋是基础,一切的前提奋之上是忍耐大部分时候大部分人的“习惯”都是跟“效率”作对的奋让你有机会去跟这些习惯做斗争在ACM竞赛的级别,写代码不是在解题,而是实现早已在脑子里准备好的一个逻辑流程。这个追求跟大部分没有训练过的人的习惯相反,要扭转这种习惯,第一步可以做尝试有:1.把准备和敲键盘分割为两个动作。2.把敲键盘和运行分割为两个动作。3.编译错误这件事情几乎总是会发生,但“尝试”减少编译错误的过程,确实对提高准备效率很有帮助帮助。写程序的准备->写代码->测试三阶段,普通人之间差距最小的就是第二个阶段。速度都是在“短到完全不充分或者长得非常没建设性”的准备期,以 阅读全文
posted @ 2012-05-06 21:28 E_star 阅读(652) 评论(0) 推荐(3) 编辑
摘要:View Code #include <cstdio>#include <cstring>#include <iostream>#include <functional>#include <queue>using namespace std;int ar[13] = {14,10,56,7,83,22,36,91,3,47,72,0};struct cmp1{ bool operator ()(int &a,int &b) { return a > b;//以后面的b为准a》b所以小的先出来 }};struct 阅读全文
posted @ 2012-03-01 16:17 E_star 阅读(273) 评论(0) 推荐(0) 编辑
摘要:float的范围为-2^128 ~ +2^127,也即-3.40E+38~ +3.40E+38;double的范围为-2^1024 ~ +2^1023,也即-1.79E+308~ +1.79E+308 阅读全文
posted @ 2012-02-24 19:43 E_star 阅读(192) 评论(0) 推荐(0) 编辑
摘要:1062* 昂贵的聘礼 枚举等级限制+dijkstra1087* A Plug for UNIX 2分匹配1094 Sorting It All Out floyd 或 拓扑1112* Team Them Up! 2分图染色+DP1125 Stockbroker Grapevine FLOYD1135 Domino Effect 最短路1149* PIGS 网络流1161* Walls floyd1201 Intervals 差分约束1236* Network of Schools 强联通1251 Jungle Roads MST1273 Drainage Ditches 最大流1274 Th 阅读全文
posted @ 2012-02-15 11:20 E_star 阅读(292) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1033给两点,然后又第二个点画线,单位长度为10,每次旋转90度,这里的陷阱是确定了顺时针后,逆时针要根据顺时针来确定。。View Code #include <cstdio>#include <iostream>#include <algorithm>#include <cstring>#define maxn 207using namespace std;int main(){ //freopen("d.txt","r" 阅读全文
posted @ 2012-02-08 18:32 E_star 阅读(203) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1098题意就是,输入k,然后求对于任意的x,使f(x)能被65整除时,最小的a;数学归纳法证明:f(x)=5*x^13+13*x^5+k*a*x第一步:f(0)=0;成立:第二步:假设f(x)能被65整除,则有5*x^13+13*x^5+k*a*x能被65整出;第三步:则f(x+1)=5*(x+1)^13+13*(x+1)^5+k*a*(x+1);根据二项式定理分析题目:f(x+1)=5*(c(13,0)+c(13,1)*x+c(13,2)*x^2+.......+c(13,13)*x^13)+13*(c(5 阅读全文
posted @ 2011-12-30 20:09 E_star 阅读(326) 评论(0) 推荐(0) 编辑
摘要:http://baike.baidu.com/view/2499752.htm卡特兰数的应用。。。http://acm.hdu.edu.cn/showproblem.php?pid=1023公式:令h(1)=1,h(2)=2,catalan数满足递归式: h(n)= h(1)*h(n-1)+h(2)*h(n-2) + ... + h(n-1)h(1) (其中n>=3) 例如:h(3)=h(1)*h(2)+h(2)*h(1)=1*1+1*1=2 h(4)=h(1)*h(3)+h(2)*h(2)+h(3)*h(1)=1*2+1*1+2*1=5 另类递归式: h(n)=h(n-1)*(4*.. 阅读全文
posted @ 2011-12-30 16:43 E_star 阅读(269) 评论(0) 推荐(0) 编辑
摘要:题目就是一个rmq算法的典型应用,关键是将其转化成rmq的形式,因为每个点都是a[i]<=a[i+1]所以对于每一个点记录他的左边与右边,因而可知他的长度(即出现的频率),然后还有一个值记录频率;最后求解是用的很巧妙的方法;View Code #include <iostream>#include <cstdio>#include <cmath>using namespace std;const int max_s = 100007;int f[25][max_s],hash[max_s],pow2[25],a[max_s];struct node{ 阅读全文
posted @ 2011-12-04 11:25 E_star 阅读(218) 评论(0) 推荐(0) 编辑
摘要:http://openoj.awaysoft.com:8080/judge/contest/view.action?cid=47#problem/G一个优先队列的题目,昨天刚做了一个用优先队列(stl)+bfs的题目,今天看到这个题瞬间1Y ou yeah!#include<iostream>#include<cstring>#include<cstdio>#include <queue>using namespace std;struct node{ char s[100]; int x,y; friend bool operator < 阅读全文
posted @ 2011-11-27 00:35 E_star 阅读(294) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示