1 #include 2 #include 3 #include 4 5 char explode( char * str , char symbol ); 6 7 8 double distance ( int x1 , int y1 , int x2 , int y...
分类:
编程语言 时间:
2014-08-26 06:24:05
阅读次数:
302
原题戳我Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You ha...
分类:
其他好文 时间:
2014-08-26 00:14:25
阅读次数:
334
https://oj.leetcode.com/problems/edit-distance/Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convertword1tow...
分类:
编程语言 时间:
2014-08-23 09:56:50
阅读次数:
213
A really classic 2D DP problem. And I'm glad that I figured out the transfer function without checking any other resources.After that, everything is s...
分类:
其他好文 时间:
2014-08-22 15:46:38
阅读次数:
232
function?radian($d)?{
????????????$d?*?3.1415926535898?/?180.0;??
}
function?distance_calculate($longitude1,?$latitude1,?$longitude2,?$latitude2)?{
???????????...
分类:
Web程序 时间:
2014-08-22 13:10:19
阅读次数:
209
与Edit Distance问题类似, 纯dp状态转移方程如下在poj上找了一道题目 poj1458, 水过代码如下 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #...
分类:
其他好文 时间:
2014-08-22 12:52:28
阅读次数:
204
在上一篇文章Levenshtein distance算法实现中,笔者已经讲解了一般最小编辑距离的算法。该算法采用动态规划,时间复杂度是O(m*n),m,n分别为两个字符串的长度,而空间复杂度也是O(m*n),如果使用int作为矩阵元素的类型,则矩阵的占用空间大小为sizeof(int)*m*n,假如两个字符串的长度均为10000个字符,则矩阵大小为400MB,相当可观。参考一个快速、高效的Leve...
分类:
其他好文 时间:
2014-08-20 12:38:02
阅读次数:
187
Levenshein distance,中文名为最小编辑距离,其目的是找出两个字符串之间需要改动多少个字符后变成一致。该算法使用了动态规划的算法策略,该问题具备最优子结构,最小编辑距离包含子最小编辑距离,有下列的公式。
其中d[i-1,j]+1代表字符串s2插入一个字母,d[i,j-1]+1代表字符串s1删除一个字母,然后当xi=yj时,不需要代价,所以和上一步d[i-1,j-1]代价相...
分类:
其他好文 时间:
2014-08-19 22:33:05
阅读次数:
323
uva 11796 Dog Distance (计算几何-点和直线)
题目大意:
两条狗匀速分别沿着折线跑,已知同时出发,同时到达,问你求相差最大的距离 与相差的最小的距离之间的差值。
解题思路:
如果两只狗都走1条线段的话,根据相对运动的理论,可以把其中一只狗看成静止不动,另一只狗相对运动,且线路为线段,那么立刻转化为点到线段的距离的问题。...
分类:
其他好文 时间:
2014-08-19 16:36:54
阅读次数:
224
/*
迭代法 :204Ms
*/
#include
#include
#include
#define N 1100
#define eps 1e-10
#define inf 0x3fffffff
struct node {
int u,v,w;
}p[N];
double ma[N][N];
double distance(int i,int j) {
return sqrt(1.0*(...
分类:
其他好文 时间:
2014-08-19 11:01:44
阅读次数:
338