
算法分析
coldfresh
那我们开始吧
展开
-
Dijkstra算法(最小路)
在图论中的一个经典求最短路的算法,基本上,所有的数据结构的书籍都会有这个算法,这算法有一个特性,我要求一个点到另一个点的最短距离,这个算法不仅给出这个最短距离还有很多“副产品”,也就是说只要在图中所有与该点连通的点,那么这些点的最短路会一并求出。 适用条件: 1.所有所有权边均为正。 2.有向/无向。 这里我们用邻接表来描述(存储)图。设点为1到n编号的店,m条边,与之对应的m个权值,x为起原创 2017-03-27 19:00:23 · 992 阅读 · 0 评论 -
最小路(Bellman-Ford算法)(负权情况)
Dellman-Ford算法原创 2017-03-27 20:51:37 · 676 阅读 · 0 评论 -
Buy the Ticket HDU - 1133 (递推+动态规划+组合)
题目: The “Harry Potter and the Goblet of Fire” will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won’t you? Suppose the cinema...原创 2017-03-21 14:22:16 · 1057 阅读 · 0 评论 -
道路和航路 (SPFA算法)(Bellman-Ford算法的优化)
最小路算法原创 2017-03-28 13:42:55 · 734 阅读 · 0 评论 -
KMP算法(字符串匹配算法)
KMP原创 2017-03-28 16:01:11 · 552 阅读 · 0 评论 -
lift and throw(from蓝桥)(深度优先搜索)
问题描述: 给定一条标有整点(1, 2, 3, …)的射线. 定义两个点之间的距离为其下标之差的绝对值. Laharl, Etna, Flonne一开始在这条射线上不同的三个点, 他们希望其中某个人能够到达下标最大的点. 每个角色只能进行下面的3种操作, 且每种操作不能每人不能进行超过一次. 1.移动一定的距离 2.把另一个角色高举过头 3.将举在头上...原创 2017-03-23 21:15:30 · 718 阅读 · 0 评论 -
Jessica's Reading Problem POJ - 3320 (尺取法)
Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas inclu原创 2017-04-23 16:20:49 · 516 阅读 · 0 评论 -
S-Nim(fromHDU)(博弈问题)(Sprague-Grundy定理)
题目描述: Arthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows: The starting position has a number of heaps, all containing some, not necessarily eq原创 2017-04-07 23:32:31 · 948 阅读 · 0 评论 -
二分法搜索的应用
二分法是一个应用比较广泛的算法,但是也因此往往被我们忽略,比如这蓝桥杯的倒数第二题,我忽略了线性枚举的超时的可能性,也竟然忘了用二分法(所幸还是进了决赛…)以防万一使用二分会保险一点,今天之所以要将这个,是因为在poj上做到了几道相似的题,所以我觉得有必要总结一下,用三道例题阐述一下:Cable master POJ - 1064 Inhabitants of the Wonderland hav原创 2017-04-23 12:10:26 · 557 阅读 · 0 评论