【poj 1080】Human Gene Functions DP(类最长公共子序列*)

SWD、JTAG协议和JLINK、STLINK仿真器 在1990年IEEE觉得一切妥当,于是发布了IEEE Standard 1149.1-1990,并命名为Standard Test Access Port and Boundary-ScanArchitecture,这就是大名鼎鼎的JTAG了。开发工程师通过结合使用RealView MDK的调试器和ULINK2,可以方便的在目标硬件上进行片上调试(使用on-chip JTAG,SWD和OCDS)、Flash编程。,是ARM设计的协议,用于对其微控制器进行编程和调试。情况下,SWD整体性能比JTAG更好。 阅读详情

Human Gene Functions
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 18529 Accepted: 10293

Description
It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their functions, because these can be used to diagnose human diseases and to design new drugs for them.

A human gene can be identified through a series of time-consuming biological experiments, often with the help of computer programs. Once a sequence of a gene is obtained, the next job is to determine its function.
One of the methods for biologists to use in determining the function of a new gene sequence that they have just identified is to search a database with the new gene as a query. The database to be searched stores many gene sequences and their functions – many researchers have been submitting their genes and functions to the database and the database is freely accessible through the Internet.

A database search will return a list of gene sequences from the database that are similar to the query gene.
Biologists assume that sequence similarity often implies functional similarity. So, the function of the new gene might be one of the functions that the genes from the list have. To exactly determine which one is the right one another series of biological experiments will be needed.

Your job is to make a program that compares two genes and determines their similarity as explained below. Your program may be used as a part of the database search if you can provide an efficient one.
Given two genes AGTGATG and GTTAG, how similar are they? One of the methods to measure the similarity
of two genes is called alignment. In an alignment, spaces are inserted, if necessary, in appropriate positions of
the genes to make them equally long and score the resulting genes according to a scoring matrix.

For example, one space is inserted into AGTGATG to result in AGTGAT-G, and three spaces are inserted into GTTAG to result in –GT–TAG. A space is denoted by a minus sign (-). The two genes are now of equal
length. These two strings are aligned:

AGTGAT-G
-GT–TAG

In this alignment, there are four matches, namely, G in the second position, T in the third, T in the sixth, and G in the eighth. Each pair of aligned characters is assigned a score according to the following scoring matrix.

denotes that a space-space match is not allowed. The score of the alignment above is (-3)+5+5+(-2)+(-3)+5+(-3)+5=9.

Of course, many other alignments are possible. One is shown below (a different number of spaces are inserted into different positions):

AGTGATG
-GTTA-G

This alignment gives a score of (-3)+5+5+(-2)+5+(-1) +5=14. So, this one is better than the previous one. As a matter of fact, this one is optimal since no other alignment can have a higher score. So, it is said that the
similarity of the two genes is 14.

Input
The input consists of T test cases. The number of test cases ) (T is given in the first line of the input file. Each test case consists of two lines: each line contains an integer, the length of a gene, followed by a gene sequence. The length of each gene sequence is at least one and does not exceed 100.

Output
The output should print the similarity of each test case, one per line.

Sample Input

2
7 AGTGATG
5 GTTAG
7 AGCTATT
9 AGCTTTAAA

Sample Output

14
21

Source
Taejon 2001

题目链接:http://poj.org/problem?id=1080
题目大意:给定两组DNA序列,要你求出它们的最大相似度
每个字母与其他字母或自身和空格对应都有一个打分,求在这两个字符串中插入空格,让这两个字符串的匹配分数最大

思路:DP 最长公共子序列思路当s1[i] == s2[j] 时dp[i][j] = dp[i-1][j-1] + 1
当s1[i] != s2[j]时,dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

——————————》dp[i][j]=dp[i-1][j-1]+val(s1[i-1],s2[j-1]);
dp[i][j]=max(dp[i][j],dp[i-1][j]+val(s1[i-1],’ ‘));
dp[i][j]=max(dp[i][j],dp[i][j-1]+val(’ ‘,s2[j-1]));

代码:

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int dp[110][110];
char s1[110],s2[110];



int l1,l2;
int T;
int val(char a,char b)
{
    if(a==b) return 5;
    if((a=='A'&&b=='C')||(a=='A'&&b=='T')||(a=='C'&&b=='A')||(a=='T'&&b=='A')||(a==' '&&b=='T')||(a=='T'&&b==' ')) return -1;
    if((a=='A'&&b=='G')||(a=='C'&&b=='T')||(a=='G'&&b=='A')||(a=='G'&&b=='T')||(a=='G'&&b==' ')||(a=='T'&&b=='C')||(a=='T'&&b=='G')||(a==' '&&b=='G')) return -2;
    if((a=='A'&&b==' ')||(a=='C'&&b=='G')||(a=='G'&&b=='C')||(a==' '&&b=='A')) return -3;
    if((a=='C'&&b==' ')||(a==' '&&b=='C')) return -4;
}
int DP()
{

    dp[0][0]=0;
    for(int i=1;i<=l1;i++)
    dp[i][0]=dp[i-1][0]+val(s1[i-1],' ');
    for(int i=1;i<=l2;i++)
    dp[0][i]=dp[0][i-1]+val(' ',s2[i-1]);

    for(int i=1;i<=l1;i++)
    for(int j=1;j<=l2;j++)
    {
        dp[i][j]=dp[i-1][j-1]+val(s1[i-1],s2[j-1]); 
        dp[i][j]=max(dp[i][j],dp[i-1][j]+val(s1[i-1],' ')); 
        dp[i][j]=max(dp[i][j],dp[i][j-1]+val(' ',s2[j-1]));
        //if(i==1&&j==7) cout<<dp[i][j]<<endl;
    }
    return dp[l1][l2];

}
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%s%d%s",&l1,s1,&l2,s2);
        printf("%d\n",DP());    
    }


}
JTAG 、 SWD 和 J-Link、ST-Link STLINK有多个版本,分别是ST-LINK/V1(已停产),ST-LINK/V2(常见于Nucleo或Discovery开发板),ST-LINK/V2-1(常见于新版Nucleo或Discovery开发板),ST-LINK/V3(最新版)。JLink是通用型的ARM内核芯片仿真器,支持的芯片和软件开发环境多 ,IAR,Keil MDK, STM32 cudeIDE,MCUXpresso IDE(GCC+Eclipse)针对NXP芯片;支持开发环境,IAR,keil MDK,STM32 cudeIDE, 阅读详情

相关推荐

开发环境 之八 详解 JTAG、SWD 接口

JTAG 和 SWD 在嵌入式开发中可以说是随处可见,他们通常被用来配合 J-Link 、ULINK、ST-LINK 等仿真器在线调试嵌入式程序。此外,还有飞思卡尔芯片中的 Background debug mode(BDM) 接口,Atmel 芯片中的 debugWIRE ;Nexus 5001 论坛制定的全球嵌入式处理器调试接口标准 IEEE-ISTO 5001。

技术干货 1万+

hdu1080 Human Gene Functions(LCS变形)

Human Gene Functions Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1338Accepted Submission(s): 767 Problem Description It is well ...

angtongyou1893的博客 296

冒泡排序的并行计算

本人也是并行计算的小白,在这里记录下自己的学习笔记。 今天做了一下冒泡排序的并行计算比较: 串行冒泡排序如下: #include <stdio.h> #include <stdlib.h> #include <windows.h> void BubbleSort(int * pData, int nSize) { if (!pData) { ...

gaoyi的专栏 4498

Human Gene Functions(dp)

题目描述 众所周知,人类基因可以认为是一个基因序列,包含四种核苷酸,分别用A,C,T和G四个字母简单地表示。生物学家对鉴别人类基因并确定他们的功能很感兴趣,因为这对诊断人类疾病和开发新药很有用。…… 你的任务是编写一个程序,按以下规则比较两个基因并确定它们的相似程度。 给出两个基因AGTGATG和GTTAG,他们有多相似呢?测量两个基因相似度的一种方法称为对齐。使用对齐方法,可以在基因的适当位置插进空格,让两个基因的长度相等,然后根据基因分值矩阵计算分数。 例如,给AGTGATG插入一个空格,就得到AGT

qq_51772871的博客 822

在mdk文件移植太多_XCubeClassB代码 的移植

前言ST在www.st.com官网上提供了针对IEC60730/IEC60335 ClassB认证的软件包。软件包分为三个,分别适用STM8,STM32(基于标准外设库)和STM32(基于HAL库):STM8-SafeCLASSB,STM32-CLASSB-SPL,X-CUBE-CLASSB。本文以X-CUBE-CLASSB为例介绍如何做代码的移植以及经常遇到的问题的解决办法。X-CUB...

weixin_28898707的博客 1839

告别Docker Desktop!Colima在Mac上的5分钟极速安装与配置指南(M1芯片实测)

本文详细介绍了如何在Mac(尤其是M1芯片)上快速安装和配置Colima,作为Docker Desktop的免费替代品。通过优化配置和实战指南,帮助开发者提升容器运行效率,减少资源占用,实现丝滑的开发体验。

weixin_28839601的博客 452

【dp】POJ - 1080 Human Gene Functions

【dp】POJ - 1080 Human Gene Functions【poj链接】 【vj链接】题目大意给两个字符串包括A,C,G,T,一一对应的组合有权重,加入’-‘使两字符串长度相等,求最大权重和,注意:两个’-‘不可对应。 InputThe input consists of T test cases. The number of test cases ) (T is given in

xuziling_的博客 203

【微信小程序开发与设计】垃圾智能分类小程序

垃圾分类是将来生活可持续发展的必需项。但是很多人由于缺乏垃圾分类知识,或是因为垃圾分类困难,费时费力,所以没有好好贯彻垃圾分类政策,此时设计一款方便于群众进行智能化垃圾识别分类的微信小程序就显得尤为必要。

Markelle_Fultz的博客 8246

poj1080 - Human Gene Functions

想看更多的解题报告: http://blog.csdn.net/wangjian8006/article/details/7870410                                      转载请注明出处:http://blog.csdn.net/wangjian8006 题目大意:给出两个字符串,要使他们对齐,比如: AGTGATG GTTAG 这两个字符串可以

贰圣 2535

D触发器版图设计的艺术:最小化面积与最大化性能的平衡之道

本文探讨了D触发器版图设计中如何平衡最小化面积与最大化性能的核心挑战。通过分析晶体管布局、互联优化、时钟分布等关键策略,结合先进制程下的功耗与信号完整性考量,为数字IC工程师提供了从基础优化到制造验证的实用解决方案,助力实现高性能、低面积的芯片设计。

aa123的博客 914

OCR技术解析:用Tesseract和PaddleOCR识别文本

OCR技术解析:用Tesseract和PaddleOCR识别文本 ,人工智能,计算机视觉,大模型,AI,光学字符识别(Optical Character Recognition,简称 OCR)是一项将图片、扫描件等文档中的文字信息转换为可编辑文本的技术。在数字化时代,OCR 技术广泛应用于文档处理、车牌识别、身份证识别、古籍数字化等领域,极大地提高了文字信息处理的效率。Tesseract 和 PaddleOCR 是两款极具代表性的 OCR 工具。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 3万+

Human Gene Functions POJ - 1080

类似LCS匹配 #include&amp;lt;cstdio&amp;gt; #include &amp;lt;algorithm&amp;gt; using namespace std; #define fst first #define sec second #define sci(num) scanf(&quot;%d&quot;,&amp;amp;num) #define scl(num) scanf(&quot;%lld&qu

KLChen的博客 206

鸿蒙ArkUI内部API10以及11开发,输入框唤起输入法键盘,页面会被顶起的解决办法

鸿蒙ArkUI内部API10以及11开发,输入框唤起输入法键盘,页面会被顶起的解决办法

zmx781284440的博客 3219

POJ 1080 Human Gene Functions(dp)

题意:给定两个字符串,求它们对齐匹配的最大值 要求:可以两个字符匹配,也可以一个字符和‘-’匹配, 但是不能两个‘-’匹配,例如: AGTGATG GTTAG 这两个字符串可以看成是 AGTGATG -GTTA-G 也可以看成是 AGTGAT-G -GT--TAG 分析:这是一个变形的最长公共子序列,最优解: 1.取字符i-1和j-1的时候dp[i][j]=dp[...

dianche1354的博客 158

基于FPGA的BP神经网络Verilog设计与Matlab仿真

BP(Backpropagation)神经网络是一种常见且广泛应用的神经网络类型,通过反向传播算法实现训练和学习。本文将介绍如何使用Verilog语言在FPGA上设计一个简易的BP神经网络,并使用Matlab进行仿真验证。BP神经网络由输入层、隐藏层和输出层组成。在上述Verilog代码中,我们定义了BP神经网络的输入层、隐藏层和输出层的神经元数量,并声明了相应的信号和参数。在上述Verilog代码中,我们定义了BP神经网络的输入层、隐藏层和输出层的神经元数量,并声明了相应的信号和参数。

2301_79326254的博客 563

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

hdu 1080 ;poj 1080 Human Gene Functions

求两串字符串的匹配。类似于求最长

Gavin的专栏 611

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

【POJ 1080】 Human Gene Functions

【POJ 1080】 Human Gene Functions类似于最长公共子序列的做法 dp[i][j]表示 str1[i]对应str2[j]时的最大得分 转移方程为 dp[i][j]=max(dp[i-1][j-1]+score[str1[i]][str2[j]], max(dp[i-1][j]+score[str1[i]][‘-‘],dp[i][j-1]+score[‘-‘][str2

ACMer' 1076

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

poj 1080 Human Gene Functions

这是一道比较经典的DP,两串基因序列包含A、C、G、T,每两个字母间的匹配 产生一个相似值,求基因序列(字符串)匹配的最大值。  这题有点像求最长公共子序列。只不过把求最大长度改成了求最大的匹配值。用二 组opt[i][j]记录字符串a中的前i 个字符与字符串b中的前j 个字符匹配所产生的最大值 如已知AG和GT的最大匹配值,AGT和GT的最大匹配值,AG和GTT的最大匹配 求AGT和G

hpyhpy548的专栏 553

POJ 1080 Human Gene Functions(DP:LCS)

题意: 人类基因有两条,现在给出两个字符串,有长有短,可以在字符串中插入空格,要求对照表使两个字符串得出的相似值最大。 要点: 是LCS的变形,用dp[i][j]存储第一个字符串前i个字符与第二个字符串前j个字符的相似值的最大值,可以这么理解,要么就两个字符串都不加空格,要么其中一个加一个不加。这样可以写出状态转移方程为:dp[i][j]=max(dp[i - 1][j - 1] + mat

SeasonJoe的博客 369

POJ1080Human Gene Functions(LCS变形)

题目链接 题目:给出两个串,每匹配一种有一种权值,求权值最大的匹配串 就是 最长公共子序列的 的思想: 首先对于 i 和 j 来比较, 一种情况是i和j匹配,此时 dp[i][j] = dp[i - 1][j - 1] + g[ str1[i] ][ str2[j] ],另一种情况是i和j不匹配,那么就有两种情况,一 i 和 j前面的匹配,j与一个空 即 ‘ - ’匹配,dp[i][...

apk6909的博客 139

POJ - 1080 Human Gene Functions (LCS变形)

题目链接: [Human Gene Functions] 大致题意: 给定两个字符串 s1 和 s2 ,在两个串中都可以插入空格,使两个串的长度最后相等,然后开始匹配,怎样插入空格由匹配规则得到的值最大 解题思路: LCS的变形 状态转移: dp[i] [j] = max(dp[i - 1][j - 1] + match[s1[i]][s2[j]], dp[i - 1][j] + match[s1[i]][’ ‘]); dp[i][j] = max(dp[i][j], dp[i][j - 1] + ma

qq_49494204的博客 176

POJ 1080 Human Gene Functions 【DP】

题目链接:http://poj.org/problem?id=1080 分析:简单的动态规划,类似于最长公共子序列。当前状态dp[i][j]是从前面三个状态转移而来: 1、dp[i-1][j]转移到dp[i][j]即s1[i]所对的字母和'-'匹配; 2、dp[i][j-1]转移到dp[i][j]即s2[i]所对的字母和'-'匹配 3、dp[i-1][j-1]转移到dp[i][j]即s1[

Jane_JXR的博客 478

POJ - 1080 - Human Gene Functions (LCS的变形)

题目传送:Human Gene Functions 思路:LCS的变形,定义状态dp[ i ][ j ]为取字符串s前i个字符字符串t前j个字符所获得的最大值,则可以得到状态转移方程为: dp[ i ][ j ] = max(dp[ i ][ j - 1] + f[ ' - ' ][ t[ j ] ], dp[ i - 1 ][ j ] + f[ s [ i ] ][ ' - ' ],

Never say never 790

POJ 1080 Human Gene Functions(动态规划)

挺经典的DP题目,LCS变形,注意边界处理!

公孙轩辕,一眼千年 842

POJ 1080 Human Gene Functions(LCS变形)

POJ 1080 Human Gene Functions题目大意 求两基因的相似度,可以在每个基因对中加入若干空格,每个字母与其他字母或自身和空格对应都有一个打分,则相似度就是最大的得分和 分析LCS变形,我采用的是递归的写法 dp[i][j]表示第一串前i个字符,第二串前j个字符匹配所能得到的最大分数和。状态和状态的转移都类似于最长公共子序列问题(LCS)只是字符和字符匹配的分数不是固定的

AIDreamer 367
上一篇: 【poj 3176】 Cow Bowling 递推dp
下一篇: 【poj 2479】Maximum sum DP
ALPS233
博客等级 码龄11年 25粉丝 191原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值