A2528 | 相似基因
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
大家都知道,基因可以看作一个碱基对序列。它包含了 $4$ 种核苷酸,简记作
在一个人类基因工作组的任务中,生物学家研究的是:两个基因的相似程度。因为这个研究对疾病的治疗有着非同寻常的作用。两个基因的相似度的计算方法如下:
对于两个已知基因,例如
$$ \def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|c|c|} \hline \tt A & \tt G & \tt T & \tt G & \tt A & \tt T & \texttt - & \tt G \\ \hline \texttt - & \tt G & \tt T & \texttt - & \texttt - & \tt T & \texttt A & \tt G \\ \hline \end{array} $$
这样,两个基因之间的相似度就可以用碱基之间相似度的总和来描述,碱基之间的相似度如下表所示:
$$ \def\arraystretch{1.5} \begin{array}{ |c|c|c|c|c|c|} \hline & \tt A & \tt C & \tt G & \tt T & \texttt - \\ \hline \tt A & 5 & -1 & -2 & -1 & -3\\ \hline \tt C & -1 & 5 & -3 & -2 & -4 \\\hline \tt G & -2 & -3 & 5 & -2 & -2 \\\hline \tt T & -1 & -2 & -2 & 5 & -1 \\\hline \texttt - & -3 & -4 & -2 & -1 & * \\\hline \end{array} $$
那么相似度就是:$(-3)+5+5+(-2)+(-3)+5+(-3)+5=9$。因为两个基因的对应方法不唯一,例如又有:
$$ \def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|c|} \hline \tt A & \tt G & \tt T & \tt G & \tt A & \tt T & \tt G \\ \hline \texttt - & \tt G & \tt T & \texttt T & \texttt A & \texttt - & \tt G \\ \hline \end{array} $$
相似度为:$(-3)+5+5+(-2)+5+(-1)+5=14$。规定两个基因的相似度为所有对应方法中,相似度最大的那个。
A, C, G, T。生物学家正致力于寻找人类基因的功能,以利用于诊断疾病和发明药物。在一个人类基因工作组的任务中,生物学家研究的是:两个基因的相似程度。因为这个研究对疾病的治疗有着非同寻常的作用。两个基因的相似度的计算方法如下:
对于两个已知基因,例如
AGTGATG 和 GTTAG,将它们的碱基互相对应。当然,中间可以加入一些空碱基 -,例如:$$ \def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|c|c|} \hline \tt A & \tt G & \tt T & \tt G & \tt A & \tt T & \texttt - & \tt G \\ \hline \texttt - & \tt G & \tt T & \texttt - & \texttt - & \tt T & \texttt A & \tt G \\ \hline \end{array} $$
这样,两个基因之间的相似度就可以用碱基之间相似度的总和来描述,碱基之间的相似度如下表所示:
$$ \def\arraystretch{1.5} \begin{array}{ |c|c|c|c|c|c|} \hline & \tt A & \tt C & \tt G & \tt T & \texttt - \\ \hline \tt A & 5 & -1 & -2 & -1 & -3\\ \hline \tt C & -1 & 5 & -3 & -2 & -4 \\\hline \tt G & -2 & -3 & 5 & -2 & -2 \\\hline \tt T & -1 & -2 & -2 & 5 & -1 \\\hline \texttt - & -3 & -4 & -2 & -1 & * \\\hline \end{array} $$
那么相似度就是:$(-3)+5+5+(-2)+(-3)+5+(-3)+5=9$。因为两个基因的对应方法不唯一,例如又有:
$$ \def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|c|} \hline \tt A & \tt G & \tt T & \tt G & \tt A & \tt T & \tt G \\ \hline \texttt - & \tt G & \tt T & \texttt T & \texttt A & \texttt - & \tt G \\ \hline \end{array} $$
相似度为:$(-3)+5+5+(-2)+5+(-1)+5=14$。规定两个基因的相似度为所有对应方法中,相似度最大的那个。
输入格式
共两行。每行首先是一个整数 $n$,表示基因序列的长度;隔一个空格后是一个基因序列,序列中只含 $\verb!A!,\verb!C!,\verb!G!,\verb!T!$ 四种字母。$1 \le n\le 100$。
输出格式
仅一行,即输入基因的相似度。
输入输出样例
输入 #1
7 AGTGATG 5 GTTAG
输出 #1
14
仅一行,即输入基因的相似度。
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted