There are given two strings, A and B. An expansion of some string X is a string created by adding or inserting any number (zero, one or more) of blanks anywhere in the string, or in the begining or the end of the string. Eg., if the string X is ‘abcbcd’, then the strings 'abcb-cd', '-a-bcbcd-' and 'abcb-cd-' are expansions of the string X (blanks are denoted by the character ‘-‘).

If A1 is an expansion of the string A, and B1 is and expansion of the string B, and if A1 and B1 are of the same length, then we define the distance of the strings A1 and B1 as the sum of the distances of the characters on the same positions in these strings. We define the distance of two characters as the absolute difference of their ASCII codes, except the distance of the blank and another character, which is given (and equal for all characters).

You are to write a program which finds the expansions A1 and B1 of strings A and B, that have the smallest difference.

Input

The first line of the input file consists of the string A, and the second line of string B. They are consisted only of lower case characters of the english alphabet (a-z), and the number of characters in any of the strings is less than or equal to 2000.

The third line consists of an integer K, 1 ≤ K ≤ 100, the distance of the blank and the other characters.

Output

The first only line of the input file should consist of the smallest distance as defined in the text of the task.

Sample

Input:
cmc
snmn
2 output:
10
Input:
koiv
ua
1 output:
5
input:
mj
jao
4 output:
12 题目大意:添加空格使得两个字符串的 距离值最小。
类似于 lcs 写法
题目中 k是 字符和空格之间的距离。 这里的‘距离’是题目中定义的
/* ***********************************************
Author :guanjun
Created Time :2016/9/4 18:45:31
File Name :1001.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
char s[],t[];
int dp[][];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int k;
scanf("%s %s %d",s+,t+,&k);
int n=strlen(s+);
int m=strlen(t+);
//dp[0][0]=0;
for(int i=;i<=n;i++)dp[i][]=k*i;
for(int i=;i<=m;i++)dp[][i]=k*i;
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
dp[i][j]=min(dp[i-][j-]+abs(s[i]-t[j]),min(dp[i-][j],dp[i][j-])+k);
}
}
cout<<dp[n][m]<<endl;
return ;
}

MBLAST - BLAST的更多相关文章

  1. the comment lines of the blast tabular format

    进行Blast比对,用参数-m 6 可以以列表的方式输出结果,结果中从左到右每一列的意义分别是: [00] Query id [01] Subject id [02] % identity [03] ...

  2. Blast本地化

    转载]Blast本地化:使用Blastall进行数据库比对 (2012-02-13 21:25:31)   用blastall进行序列比对 blastall是最常用的blast程序之一,其功能非常强大 ...

  3. 本地blast用法

    格式化数据库: makeblastdb -in db.fasta -dbtype prot -parse_seqids -out dbname 参数说明: -in:待格式化的序列文件 -dbtype: ...

  4. BLAST - 序列数据库搜索

    我生信入门,老师就要求我学好blast比对,说得也确实是很有道理,是个人都知道比对是最基本的东西,现在再想想那老师的建议,也只能呵呵一笑. 北大生物信息公开课有一章专门讲得序列数据库搜索,可以好好看看 ...

  5. Blast使用详解

    Blast,全称Basic Local Alignment Search Tool,即"基于局部比对算法的搜索工具",由Altschul等人于1990年发布.Blast能够实现比较 ...

  6. 本人开发的JavaWeb急速框架Blast上线了

    JAVA 急速WEB框架Blast --对JavaWeb的学习性框架,参考了spring的实现 --阅读Blast源码可以快速掌握JavaWeb常用技术和方法论,并付诸实践 Blast 是基于 Jav ...

  7. linux blast

    建库 减压后,改名为blast,并在blas目录在建立db文件1,建立数据库makeblastdb -in db.fasta -dbtype nucl(prot) -parse_seqids -has ...

  8. 关于生物项目上的blast和viroblast

    最近要做一个跟生物有关的项目,隔行如隔山呀,好多工具以前都没听过,blast分到我头上啦,查查,查查 BLAST (Basic Local Alignment Search Tool)是一套在蛋白质数 ...

  9. Blast

    NCBI 教程:https://www.ncbi.nlm.nih.gov/books/NBK279681/ 本地使用 blast 的步骤 1. 构建本地数据库索引 $makeblastdb -in h ...

随机推荐

  1. KM算法(Kuhn-Munkres)

    算法理论基础: 可行顶点标号 用l(v)表示顶点v的标号,w(uv)表示边(u,v)的权,对于赋权二分图G=(X,Y),若对每条边e=xy,均有l(x)+l(y)>=w(xy),则称这个标号为G ...

  2. 表格 —— 一个单元格插入多个tags

    <st #st [columns]="columns" [data]="data" [bordered]='true'> <ng-templa ...

  3. 梦想CAD控件打印相关

    一.打印设置 在顶部快速访问工具栏单击打印按钮或者直接输入PLOT命令或者点击打印控制的打印设置按钮打开打印对话框.c#代码实现如下: //打印设置 private void Print1() {   ...

  4. Android开发使用控件入门--环境搭建

    Android开发使用控件入门--环境搭建 软件名称(,梦,,想.CAD  ,控件) 1. 环境搭建: 3 1.1. 安装Eclipse 3 1.2. 下载JDK 3 1.3. 下载Android S ...

  5. XGBoost参数中文翻译以及参数调优

    XGBoost:参数解释:https://blog.csdn.net/zc02051126/article/details/46711047 机器学习系列(11)_Python中Gradient Bo ...

  6. node-sass安装失败的解决方案

    这是一个老生常谈的问题了,网上有很多解决方法,找一个自己觉得合适的才是最重要的...... 执行以下命令即可: npm config set sass_binary_site https://npm. ...

  7. 基于springmvc、ajax,后台连接数据库的增删改查

    前言 前段时间在博客园上找了一个springmvc的例子,照着学了一下,算是对springmvc有了一个初步的了解,打一个基础,下面是链接.(我只看了博客,视频太耗时间了) 博客链接:http://w ...

  8. [USACO15JAN]Grass Cownoisseur

    \(tarjan\)缩点+\(DAG\)上最长路. 求一个以\(1\)为起点的最长路和一个以\(1\)为终点的最长路,然后找那个逆行边就行了. 然后这个我\(RE\)了好久,原因是\(vector\) ...

  9. 第八节:web爬虫之urllib(四)

    第三个 模块parse : 是一个工具模块,提供了许多 URL 处理方法,比如拆分.解析.合并等等的方法.

  10. 【模板】51nod 1006 最长公共子序列Lcs

    [题解] dp转移的时候记录一下,然后倒着推出答案即可. #include<cstdio> #include<cstring> #include<algorithm> ...