【编程题】(满分27分)

脱氧核糖核酸即常说的DNA,是一类带有遗传信息的生物大分子。它由4种主要的脱氧核苷酸(dAMP、dGMP、dCMT和dTMP)通过磷酸二酯键连接而成。这4种核苷酸可以分别记为:A、G、C、T。

DNA携带的遗传信息可以用形如:AGGTCGACTCCA.... 的串来表示。DNA在转录复制的过程中可能会发生随机的偏差,这才最终造就了生物的多样性。

为了简化问题,我们假设,DNA在复制的时候可能出现的偏差是(理论上,对每个碱基被复制时,都可能出现偏差):

  1. 漏掉某个脱氧核苷酸。例如把 AGGT 复制成为:AGT

2. 错码,例如把 AGGT 复制成了:AGCT

3. 重码,例如把 AGGT 复制成了:AAGGT

如果某DNA串a,最少要经过 n 次出错,才能变为DNA串b,则称这两个DNA串的距离为 n。

例如:AGGTCATATTCC 与 CGGTCATATTC 的距离为 2

你的任务是:编写程序,找到两个DNA串的距离。

【输入、输出格式要求】

用户先输入整数n(n<100),表示接下来有2n行数据。

接下来输入的2n行每2行表示一组要比对的DNA。(每行数据长度<10000)

程序则输出n行,表示这n组DNA的距离。

例如:用户输入:
3
AGCTAAGGCCTT
AGCTAAGGCCT
AGCTAAGGCCTT
AGGCTAAGGCCTT
AGCTAAGGCCTT
AGCTTAAGGCTT

则程序应输出:
1
1
2

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <ctime>
#include <iomanip>
using namespace std;
const int INF=0x7ffffff;
const double EXP=1e-;
const int MS=;
typedef long long LL;
int dp[MS][MS]; int minv(int a,int b,int c)
{
return a>b?(b>c?c:b):(a>c?c:a); // min(a,min(b,c))
}
/*
ACT
ACTT dp[i][j]=dp[i][j-1]+1; ACTT
ACT dp[i][j]=dp[i-1][j]+1 丢失等效于增加 ACT
ACG dp[i][j]=d[i-1][j-1]+1 */ void solve(string &s1,string &s2)
{
int len1=s1.length();
int len2=s2.length();
for(int i=;i<=len1;i++)
dp[i][]=i;
for(int i=;i<=len2;i++)
dp[][i]=i;
for(int i=;i<=len1;i++)
{
for(int j=;j<=len2;j++)
{
if(s1[i-]==s2[j-])
dp[i][j]=dp[i-][j-];
else
{ // 增加 减少 修改
dp[i][j]=minv(dp[i][j-]+,dp[i-][j]+,dp[i-][j-]+);
}
}
}
cout<<dp[len1][len2]<<endl;
return ;
} int main()
{
int n;
string str1,str2;
cin>>n;
while(n--)
{
cin>>str1>>str2;
solve(str1,str2);
}
return ;
}

DNA比对的更多相关文章

  1. [LeetCode] Repeated DNA Sequences 求重复的DNA序列

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  2. DNA解链统计物理

    来源:Kerson Huang, Lectures on Statistical Physics and Protein Folding, pp 24-25 把双链DNA解开就像拉拉链.设DNA有\( ...

  3. AC自动机+DP HDOJ 2457 DNA repair(DNA修复)

    题目链接 题意: 给n串有疾病的DNA序列,现有一串DNA序列,问最少修改几个DNA,能使新的DNA序列不含有疾病的DNA序列. 思路: 构建AC自动机,设定end结点,dp[i][j]表示长度i的前 ...

  4. [Leetcode] Repeated DNA Sequences

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  5. 利用Python【Orange】结合DNA序列进行人种预测

    http://blog.csdn.net/jj12345jj198999/article/details/8951120 coursera上 web intelligence and big data ...

  6. cfDNA(circulating cell free DNA)全基因组测序

    参考资料: [cfDNA专题]cell-free DNA在非肿瘤疾病中的临床价值(好) ctDNA, cfDNA和CTCs有什么区别吗? cfDNA你懂多少? 新发现 | 基因是否表达,做个cfDNA ...

  7. 3.Complementing a Strand of DNA

    Problem In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'. The r ...

  8. 2. Transcribing DNA into RNA

    Problem An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'. Given ...

  9. 1.Counting DNA Nucleotides

    Problem A string is simply an ordered collection of symbols selected from some alphabet and formed i ...

  10. leetcode 187. Repeated DNA Sequences 求重复的DNA串 ---------- java

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

随机推荐

  1. Tip提示框另类写法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. [Hive - LanguageManual] Statistics in Hive

    Statistics in Hive Statistics in Hive Motivation Scope Table and Partition Statistics Column Statist ...

  3. Hadoop学习之--Capaycity Scheduler配置参数说明

    以下列举出来的是capacity关于queue和user资源使用量相关的参数说明: mapred.capacity-scheduler.queue.xxx.capacity: 队列的资源容量百分比,所 ...

  4. Visual Studio 2013智能提示失效解决办法

    各种解决VS2013智能提示失效办法: 1.重置所有设置    工具->导入导出设置->重置所有设置 2.智能提示开关: 工具->选项->文本编辑器->C#->常规 ...

  5. C语言break语句

    break语句不能用于循环语句和switch语句之外的任何其他语句中: breakh中断switch break如果用于循环,是用来终止循环:break如果用于switch,则是用于终止switch. ...

  6. 从0,1,2...n中统计0,1,2...9各出现了多少次【SWUN1597】

    题目就是说给你一个N.计算一下从0,1,2,3,4,5,,,,,,n-1,n中计算出0,1,2,3,,,,7,8,9分别出现了多少次... #include<cstdio> #includ ...

  7. PDB符号文件信息

    一.前言 这个方法是通过网上的一些方式自己学习枚举PDB文件信息. 二.代码实现 首先枚举驱动文件,这里用psapi库 #include "psapi.h" #pragma com ...

  8. phper 要求

    做了这么多年php,今天看到一个07年的老文,才发现自己的水平太菜.转过来激励下自己 说句实话,写这个真够无聊的.本来看了某位大虾的类似文章,腹诽了几句也就算了.但是昨天晚上有个客户拿着这篇文章问我: ...

  9. NEUOJ 1117: Ready to declare(单调队列)

    1117: Ready to declare 时间限制: 1 Sec  内存限制: 128 MB 提交: 358  解决: 41 [提交][状态][pid=1117" style=" ...

  10. linux php开启openssl

    1.测试openssl是否安装查看版本  openssl version查看路径  which openssl2.因为要扩展php扩展模块,所以要通过phpize可以建立php的外挂模块find / ...