hdu 1080 Human Gene Functions(dp)

北大POJ1080-Human Gene Functions 立即下载

Human Gene Functions

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


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

 

思路:dp[i][j]为两个序列前i位与前j位最优配对的值。

          s【】【】为对准分数g1【】为第一个序列g2[]为第二个序列

         也就是三种配对中取最大,g1[i]与空,空与g2[j],g[i]与g[j]

          dp[i][j]=max(dp[i-1][j]+s[g1[i-1]]['-'],dp[i][j-1]+s['-'][g2[j-1]],dp[i-1][j-1]+s[g1[i-1]][g2[j-1]]);

 

dai代码:

#include<iostream>
#include<cstring>
using namespace std;
const int mm=110;
int s[][5]={{5,-1,-2,-1,-3},
            {-1,5,-3,-2,-4},
            {-2,-3,5,-2,-2},
            {-1,-2,-2,5,-1},
            {-3,-4,-2,-1,0}
};
int dp[mm][mm];
char g1[mm],g2[mm];
int len1,len2;
int k(char x)
{
  if(x=='A')return 0;
  if(x=='C')return 1;
  if(x=='G')return 2;
  if(x=='T')return 3;
  return 4;
}
int main()
{
  int cas;
  while(cin>>cas)
  {while(cas--)
    {cin>>len1>>g1>>len2>>g2;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=len1;i++)///边界条件全空与序列配对
      dp[i][0]=dp[i-1][0]+s[k(g1[i-1])][k('-')];
    for(int i=1;i<=len2;i++)
      dp[0][i]=dp[0][i-1]+s[k('-')][k(g2[i-1])];
    for(int i=1;i<=len1;i++)
      for(int j=1;j<=len2;j++)
    {
        dp[i][j]=max(dp[i][j-1]+s[k('-')][k(g2[j-1])],max(dp[i-1][j]+s[k(g1[i-1])][k('-')],
                                                          dp[i-1][j-1]+s[k(g1[i-1])][k(g2[j-1])]));
    }
    cout<<dp[len1][len2]<<"\n";
   }
  }
}


 

 

 

实战封神!YOLOv7 轻量化部署全攻略:ONNX格式转换+TensorRT极致加速(速度直接提升3-5倍,精度无损) 部署核心链路,这是YOLO系列部署的最优解,速度提升3~5倍,精度无损;ONNX是桥梁:解决模型兼容性问题,简化后能去掉冗余节点,是TensorRT加速的前提;TensorRT是核心:NVIDIA显卡的极致加速引擎,FP16量化是速度与精度的最优平衡,无需手动配置,一键开启;轻量化终极组合YOLOv7-tiny + 416尺寸 + TensorRT FP16,速度提升5~8倍,满足所有实时检测场景;避坑核心:转换参数必加,推理尺寸必须一致,engine文件显卡专属。 阅读详情

相关推荐

Win11系统下Abaqus 2025子程序开发环境一站式配置指南

本文详细介绍了在Win11系统下配置Abaqus 2025子程序开发环境的完整流程,包括VS2022和Intel oneAPI的安装与优化,以及Abaqus 2025的目录规划与环境联调。通过避坑指南和实战案例,帮助用户高效完成开发环境配置,避免常见错误,提升工作效率。

weixin_28717431的博客 350

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

Gazebo仿真UUV水下机器人:从环境搭建到避障算法实战

本文详细介绍了使用Gazebo仿真平台进行UUV水下机器人开发的全流程,涵盖从环境搭建、uuv_simulator配置、传感器集成到核心避障算法实战。通过搭建水下仿真实验室并实现基于激光雷达数据的反应式避障算法,为水下机器人算法验证与开发提供了高效、低成本的解决方案。

weixin_28840591的博客 282

Human Gene Functions(dp)

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

qq_51772871的博客 822

领域驱动新实践:COLA框架全解析——架构设计与实战案例解析

定义订单支付事件java代码解读复制代码} }Order定义Order类,继承并实现支付逻辑:java代码解读复制代码} }定义接口:java代码解读复制代码定义类,处理订单支付逻辑并持久化:java代码解读复制代码} }定义和处理订单支付事件:java代码解读复制代码} }java代码解读复制代码} }定义和接口及其实现:java代码解读复制代码java代码解读复制代码。

2401_89221445的博客 2683

动态博弈、威胁与承诺(博弈论入门学习笔记四)

0 动态博弈 动态博弈:行动有先后顺序,不同的参与人在不同时点行动,先行动者的选择影响后行动者的选择空间,后行动者可以观察到先行动者做了什么选择。例如下棋、消费者和商家讨价还价、谈婚论嫁、企业之间的价格战等等。 因此,为了做出最优的行动选择,每个参与人都应该思考:如果我如此选择,对方将如何应对?如果我是他,我将会如何行动?给定他的应对,什么是我的最优选择? 动态博弈中的战略:在博弈开始之前就...

stepho的博客 1万+

PKU1080 Human Gene Functions

/*Human Gene FunctionsTime Limit: 1000MS        Memory Limit: 10000KTotal Submissions: 6974        Accepted: 3861DescriptionIt is well known that a human gene can be considered as a sequen

zonelight的专栏 793

MT5策略如何设置回测结果才能最接近实盘

摘要:在MT5回测中,选择"每笔分笔报价"模式最接近实盘交易,因其使用真实Tick数据模拟价格波动、点差和滑点。关键设置包括:下载高质量历史数据、合理设定点差和滑点、使用正常回测速度。该模式能准确测试挂单、止盈止损等策略,虽然速度较慢但结果最可靠,避免其他模式造成的失真,是评估交易策略表现的最佳选择。(149字)

weixin_38915451的博客 1903

Human Gene Functions(动态规划)

描述: 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 id

Gabriel_tzc的博客 780

Li‘s 核磁共振影像数据处理-4-使用3D Slicer从DTI计算参数图(FA、ADC等)

从DTI计算参数图 通过3D Slicer软件计算 主要步骤 导入DICOM影像 3D Slicer似乎只能支持DICOM格式和NRRD格式的DTI处理,而无法支持NIFTI+磁场梯度信息文件的方式。(这里不确定,如有错误请指正。) 模块选择: 需要选择或设置的内容包括:选择DicomToNrrd,设置Output DWI Volume file,设置Input Dicom Data Directory。设置好后点击“Apply”。 制作mask。 实质就是去脑壳。 模块选择: 需要设置的内

weixin_38594676的博客 3927

安全监控:人员行为分析_(2).人员行为分析基础理论

人员行为分析是指利用计算机视觉技术对视频中的人类行为进行实时或离线检测、识别和理解的过程。视频采集:通过摄像头等设备获取视频数据。视频预处理:对视频数据进行噪声过滤、图像增强等处理,以便后续分析。特征提取:从视频中提取出与人员行为相关的特征,如人体姿势、动作轨迹等。行为识别:利用机器学习或深度学习模型对提取的特征进行分类,识别出具体的人员行为。行为理解:对识别出的行为进行进一步分析,理解其背后的意图或状态。在人员行为分析中,常用的公开数据集包括UCF101、HMDB51、ActivityNet等。

zhubeibei168的博客 1353

1080:Human Gene Functions(人类基因功能)(带权LCS解决基因组最大匹配)

1080:Human Gene Functions(人类基因功能)(带权LCS解决基因组最大匹配)有AC代码

guagua290290的博客 986

大华 DSS 数字监控系统 itcBulletin SQL 注入漏洞复现

大华 DSs 数字监控系统是大华开发的一款安防视频监控系统,拥有实时监视、云台操作、录像回放、报警处理、设备管理等功能。大华 DSS存在SQL注入漏洞,攻击者 pota/services/itcBuletin 路由发送特殊构造的数据包,利用报错注入获取数据库敏感信息。攻击者除了可以利用 SQL注入漏词获取数据库中的信息例如,管理员后台密码、站点的用户人人信息)之外,甚至在高权限的情况可向服务器中写入木马,进一步获取服务器系统权限poc验证是否存在漏洞如果你想查询用户名和密码。

holyxp的博客 4012

HDU 1080 Human Gene Functions (DP)

http://acm.hdu.edu.cn/showproblem.php?pid=1080 求添加  ‘-’ 后的 最大的组合值 状态转移方程: dp[i][j]=max(dp[i-1][j-1]+num[s1[i]][s2[j]], dp[i-1][j]+num[s1[i]][5], dp[i][j-1]+num[5][s2[j]] ); 由于 dp[i][0] 和dp[0][i] 的状

Napoleon 898

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

HDU 1080 Human Gene Functions DP -

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1080 #include #include #include #include using namespace std; const int maxn=100+5; const int INF=0x3f3f3f3f; #define max3(a,b,c) max(a,max(b,c)) ch

BRCOCOLI的博客 304

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

hdu 1080 Human Gene Functions dp

代码: #include #include #include #include #include #include #include #include #include #include using namespace std; const int maxn=110; int dp[maxn][maxn]; int e[5][5]={ {5,-1,-

冷月之殇 804

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

hdu 1080 Human Gene Functions 简单dp

传送门 http://acm.hdu.edu.cn/showproblem.php?pid=1080题意: - 给出两串 dna 序列, 每个碱基之间匹配得分不同要求匹配出最大得分分析: - dp[i][j] 代表匹配到第一串第 i 个和第二串第 j 个时的最大得分

nktif 309

hdu 1080 dp Human Gene Functions

分三种情况考虑。 dp[i][j]=max(dp[i-1][j-1]+a[s1[i]][s2[j]],max(dp[i-1][j]+a[s1[i]][4],dp[i][j-1]+a[s2[j]][4])); #include using namespace std; int max(int a,int b) { return a>b?a:b; } int main() { in

夜月 494

HDU 1080 Human Gene Functions dp

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1080   最大公共字符串的变形啊   xh[i][j]表示s1串前i个元素于s2串的前j个元素比较的最大值 分3中情况 1:s1[i]于s2[j]直接比较 xh[i][j]=xh[i-1][j-1]+cmp(s1[i],s2[j]); 2:s1[i]于‘-’比较 xh[i][j

lamborghini1993 967

HDU - 1080 Human Gene Functions(基础dp)

Human Gene Functions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3819    Accepted Submission(s): 2178 Problem Description It is wel

HHH_go_的博客 546

hdu 1080 Human Gene Functions--DP

#include char s1[110],s2[110]; int d[110][110]; int p[5][5]={{0,-3,-4,-2,-1},{-3,5,-1,-2,-1},{-4,-1,5,-3,-2},{-2,-2,-3,5,-2},{-1,-1,-2,-2

635

hdu1080 Human Gene Functions DP

Human Gene FunctionsTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3905    Accepted Submission(s): 2226Problem DescriptionIt is well known that...

残梦听雨 333

hdu 1080 Human Gene Functions 很霸气的DP

Human Gene Functions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1307    Accepted Submission(s): 752 Problem Description It is we

hnust_xiehonghao的专栏 1343

hdu 1080 Human Gene Functions 线性dp

#include<bits/stdc++.h> using namespace std; int a[128][128]; void init() { memset(a,0,sizeof(a)); a['A']['A']=5; a['A']['C']=-1; a['A']['G']=-2; a['A']['T']=-1; a['A']['-']=-3;

禅境花园 447

HDU 1080 Human Gene Functions 基础dp

dp黑洞再次凭一己之力写对了一道dp水题,这个题很简单,跟最长公共子序列一样。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;string.h&gt; #include&lt;algorithm&gt; #include&lt;cmath&gt; using namespace std; int t,f[105][10...

weixin_39399748的博客 231

HDU - 1080 Human Gene Functions DP

http://acm.hdu.edu.cn/showproblem.php?pid=1080 题意:           给定两个字符串 s1 和 s2 ,在两个串中都可以插入空格,使两个串的长度最后相等,然后开始匹配,怎样插入空格由匹配规则得到的值最大。 状态转移方程:           dp[i][j] = Max( dp[i-1][j] + val(str1[i],'-

菜鸟成长ing 475
上一篇: hdu 1078 FatMouse and Cheese(记忆化搜索)
下一篇: CF-12D - Ball(排序+MAP)
剑不飞
博客等级 码龄15年 86粉丝 505原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址