HDU 1080 Human Gene Functions(LCS变形)

Human Gene Functions

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2661    Accepted Submission(s): 1504


Problem 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. 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
 

Recommend
We have carefully selected several similar problems for you:   1074  1227  1224  1160  1501 
 

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)
typedef long long ll;
#define bug printf("hi\n")
#define INF 0x3f3f3f3f
#define N 100005

using namespace std;

#define N 105

int va[N*5][N*5];
char a[N],b[N];
int lena,lenb;
int dp[N][N];

void inint()
{
    va['A']['A']=5;
    va['A']['C']=-1;
    va['A']['G']=-2;
    va['A']['T']=-1;
    va['A']['-']=-3;

    va['C']['A']=-1;
    va['C']['C']=5;
    va['C']['G']=-3;
    va['C']['T']=-2;
    va['C']['-']=-4;

    va['G']['A']=-2;
    va['G']['C']=-3;
    va['G']['G']=5;
    va['G']['T']=-2;
    va['G']['-']=-2;

    va['T']['A']=-1;
    va['T']['C']=-2;
    va['T']['G']=-2;
    va['T']['T']=5;
    va['T']['-']=-1;

    va['-']['A']=-3;
    va['-']['C']=-4;
    va['-']['G']=-2;
    va['-']['T']=-1;
    va['-']['-']=-INF;
}

void DP()
{
    int i,j;
    for(i=0;i<=lena;i++)
        for(j=0;j<=lenb;j++)
          dp[i][j]=-INF;

    dp[0][0]=0;
    dp[1][0]=va[a[1]]['-'];
    dp[0][1]=va['-'][b[1]];
    for(i=1;i<=lena;i++)
       dp[i][0]=dp[i-1][0]+va[a[i]]['-'];
    for(i=1;i<=lenb;i++)
        dp[0][i]=dp[0][i-1]+va['-'][b[i]];

    for(i=1;i<=lena;i++)
        for(j=1;j<=lenb;j++)
       {
          dp[i][j]=dp[i-1][j-1]+va[a[i]][b[j]];
          dp[i][j]=max(dp[i][j],dp[i-1][j]+va[a[i]]['-']);
          dp[i][j]=max(dp[i][j],dp[i][j-1]+va['-'][b[j]]);
       }
     printf("%d\n",dp[lena][lenb]);
}

int main()
{
    int i,j,t;
    inint();

    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%s",&lena,a+1);
        scanf("%d%s",&lenb,b+1);
        DP();
    }
    return 0;
}




需求响应动态冰蓄冷系统与需求响应策略的优化研究(Matlab代码实现)内容概要:本文围绕“需求响应动态冰蓄冷系统与需求响应策略的优化研究”展开,基于Matlab代码实现,重点探讨了冰蓄冷系统在电力需求响应背景下的动态建模与优化调度策略。研究结合实际电力负荷与电价信号,构建系统能耗模型,利用优化算法对冰蓄冷系统的运行策略进行求解,旨在降低用电成本、平衡电网负荷,并提升能源利用效率。文中还提及该研究为博士论文复现,涉及系统建模、优化算法应用与仿真验证等关键技术环节,配套提供了完整的Matlab代码资源。; 适合人群:具备一定电力系统、能源管理或优化算法基础,从事科研或工程应用的研究生、高校教师及企业研发人员,尤其适合开展需求响应、综合能源系统优化等相关课题研究的人员。; 使用场景及目标:①复现博士论文中的冰蓄冷系统需求响应优化模型;②学习Matlab在能源系统建模与优化中的具体实现方法;③掌握需求响应策略的设计思路与仿真验证流程,服务于科研项目、论文写作或实际工程方案设计。; 阅读建议:建议结合提供的Matlab代码逐模块分析,重点关注系统建模逻辑与优化算法的实现细节,按文档目录顺序系统学习,并尝试调整参数进行仿真对比,以深入理解不同需求响应策略的效果差异。
综合能源系统零碳优化调度研究(Matlab代码实现)内容概要:本文围绕“综合能源系统零碳优化调度研究”,提供了基于Matlab代码实现的完整解决方案,重点探讨了在高比例可再生能源接入背景下,如何通过优化调度实现零碳排放目标。文中涉及多种先进优化算法(如改进遗传算法、粒子群优化、ADMM等)在综合能源系统中的应用,涵盖风光场景生成、储能配置、需求响应、微电网协同调度等多个关键技术环节,并结合具体案例(如压缩空气储能、光热电站、P2G技术等)进行建模与仿真分析,展示了从问题建模、算法设计到结果验证的全流程实现过程。; 适合人群:具备一定电力系统、能源系统或优化理论基础,熟悉Matlab/Simulink编程,从事新能源、智能电网、综合能源系统等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①开展综合能源系统低碳/零碳调度的科研建模与算法开发;②复现高水平期刊(如SCI/EI)论文中的优化模型与仿真结果;③学习如何将智能优化算法(如遗传算法、灰狼优化、ADMM等)应用于实际能源系统调度问题;④掌握Matlab在能源系统仿真与优化中的典型应用方法。; 阅读建议:建议结合文中提供的Matlab代码与网盘资源,边学习理论模型边动手调试程序,重点关注不同优化算法在调度模型中的实现细节与参数设置,同时可扩展应用于自身研究课题中,提升科研效率与模型精度。
本系统采用Java作为核心编程语言,基于Spring Boot框架构建,运行环境配置为JDK 1.8与Tomcat 7应用服务器。数据存储选用MySQL 5.7数据库,并借助Navicat 11进行数据库管理操作。开发工具可在Eclipse、MyEclipse或IntelliJ IDEA中任选,项目依赖管理通过Maven 3.3.9完成。 该简历管理平台在架构设计阶段,着重强化了代码结构的清晰度与可维护性,同时兼顾系统的实用价值与扩展灵活性。整体设计遵循通用化原则,确保后期维护简便,用户界面力求直观简洁。 系统通过标签分类机制实现功能模块化管理,主要包含以下三个角色维度: 管理员端涵盖综合管理功能:包括控制面板、用户账户管理、简历模板维护、模板分类设置、招聘会组织、报名信息处理、上传简历审核、求职社区管理、收藏夹维护及系统参数配置。 普通用户端提供个性化功能:涉及个人中心、招聘活动报名、简历文件上传及个人收藏记录管理。 公共访问端集成信息展示与交互模块:主要展示首页内容、简历模板库、招聘会资讯、简历上传入口、求职讨论区、系统公告栏,并提供个人中心入口、后台管理通道与在线客户服务。 该系统旨在通过结构化功能设计,提升简历相关数据的管理效率与组织化程度。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值