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. POJ_2239_Selecting Courses

    题意:一周上7天课,每天12节课,学校最多开设300节不同的课,每周每种课可以只有一个上课时间或者多个上课时间(上课内容一样),问一周最多可以选多少节课. 分析:二分图最大匹配,将一周84个时间点和可 ...

  2. Window提高_3.1练习_双进程守护

    双进程守护 当打开一个进程A的时候,此进程检测是否存在进程B,如果不存在就创建进程B. 进程B的作用是检测进程A是否被关闭,如果被关闭了,就再创建一个进程A. 双进程守护A.exe代码如下: #inc ...

  3. 梦想MxWeb3D协同设计平台 2018.10.12更新

    SDK开发包下载地址: http://www.mxdraw.com/ndetail_10107.html 1. 全新的在线的三维协同设计平台,高效异步方式,基于JavaScript和WebGL技术,前 ...

  4. Java集合(一)--Comparable和Comparator

    Comparable: 是集合内部的方法实现的排序,只有一个方法 public interface Comparable<T> { public int compareTo(T o); } ...

  5. datagrid总条数

    1.getData var data=$("#dg").datagrid("getData");alert('总数据量:' + data.total)//注意你 ...

  6. css3文字渐变无效果的解决方案

    现在css3越来月流行了,为了实现一些高大上的效果,我们会用一些渐变的特效,请看文字渐变的特效代码: .title { font-size: 60px; line-height: 80px; text ...

  7. css 实现鼠标滑过流光效果

    来划我啊 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  8. TestNG多线程测试-用xml文件实现

    MultiThreadOnXml类: package com.janson.multiThread; import org.testng.annotations.Test; public class ...

  9. Python使用Flask框架,结合Highchart处理xml数据

    1.html代码 <!DOCTYPE html><html lang="en"><head>    <meta charset=" ...

  10. 动态 SQL(2)

    前面我们学习了使用动态 SQL 的 if.where.trim元素来处理一些简单查询操作,但对于一些 SQL 语句中含有 in 条件,需要迭代条件集合来生成的情况,我们就需要使用 foreach 标签 ...