PKU1080 Human Gene Functions

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: 6974        Accepted: 3861

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
*/


#include <iostream>
using namespace std;

int match[5][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 val(char a,char b)
{
    int x,y;
    if(a == 'A')
      {
          x = 0;
      }
    else if(a == 'C')
      {
          x = 1;
      }
    else if(a == 'G')
      {
          x = 2;
      }
    else if(a == 'T')
      {
          x = 3;
      }
    else
      {
          x = 4;
      }

    if(b == 'A')
      {
          y = 0;
      }
    else if(b == 'C')
      {
          y = 1;
      }
    else if(b == 'G')
      {
          y = 2;
      }
    else if(b == 'T')
      {
          y = 3;
      }
    else
      {
          y = 4;
      }
   
    return match[x][y];

}


int main(void)
{
    int cases;
    cin>>cases;
    while(cases > 0)
      {
          cases--;
          int anum,bnum;
          char a[101],b[101];
          int c[101][101];
          int i,j,tmp;
          cin>>anum;
          for(i = 1;i <= anum;i++)
          {
          cin>>a[i];
          }
          cin>>bnum;        
          for(j = 1;j <= bnum;j++)
          {
          cin>>b[j];
          }
          a[0] = '-';
          b[0] = '-';
          c[0][0] = 0;
          for(i = 1;i <= anum;i++)
          {
          c[i][0] = c[i - 1][0] + val(a[i],'-');
          }
          for(j = 1;j <= bnum;j++)
          {
          c[0][j] = c[0][j - 1] + val('-',b[j]);
          }             
          for(int i = 1;i <= anum;i++)
          {
          for(int j = 1;j <= bnum;j++)
          {
              tmp = c[i - 1][j - 1] + val(a[i],b[j]);
              tmp = (c[i][j - 1] + val('-',b[j])) > tmp?(c[i][j - 1] + val('-',b[j])):tmp;
              tmp = (c[i - 1][j] + val(a[i],'-')) > tmp?(c[i - 1][j] + val(a[i],'-')):tmp; 
              c[i][j] = tmp;
          }
          }
        cout<<c[anum][bnum]<<endl;
      }
    return 0;
}

 

用动态规划0MS过的 三种状态

c[i - 1][j - 1] + val(a[i],b[j])

c[i][j - 1] + val('-',b[j])

c[i - 1][j] + val(a[i],'-')

选其中最大的那个

注意开始的时候应该这样设置

c[0][0] = 0;

c[i][0] = c[i - 1][0] + val(a[i],'-');

c[0][j] = c[0][j - 1] + val('-',b[j]);

 

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

微波射频学习笔记18-------偶极子天线和微波天线设计介绍

几种天线设计方法的介绍 一、偶极子天线 1.天线模型 两根紧挨着的金属导体,长度均为四分之一波长,直径均远小于波长,两导体间距也远小于波长。 2.天线性能的设计因素 ① 单个导体长度L:(光速/频率)/4=四分之一波长(在空气中传播的波长),但在导体中传播,波长会变短; ② 导体半径R:远小于波长即可,使用导电率高些的材料,市面上常见直径零点几毫米就挺好,或者用波长/200,得出一个小200的值,也算远小于波长; ③ 两导体间距S:远小于波长即可,可以比半径更小点。 以上三个变量L、R、S,均可在仿真软件

Sil_sprout 1万+

Human Gene Functions(dp)

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

qq_51772871的博客 822

树莓派5新手必看:保姆级ibus中文输入法安装与配置全流程(含.bashrc设置避坑)

本文详细介绍了在树莓派5上安装和配置ibus中文输入法的完整流程,包括系统环境准备、ibus框架安装、图形界面配置及常见问题解决方案。通过清晰的步骤说明和避坑指南,帮助新手快速实现中文输入功能,提升开发效率。

weixin_29159441的博客 545

Arduino程序设计(十)8×8 共阴极LED点阵显示(MAX7219)

本文主要介绍8×8 LED点阵显示实验,分别是:1、介绍MAX7219点阵模块;2、点阵显示部分图形;3、点阵显示数字 0~9 及 26 个英文字母。1、通过上述两个点阵实验,了解了8*8点阵显示的基本原理;2、通过SPI通信控制点阵显示,学会了Arduino用SPI通信方式控制外设。

Alice的博客 1万+

pku 1080 Human Gene Functions

#include #include #include #include using namespace std;int map[5][5] = {{5, -1, -2, -1, -3}, {-1, 5, -3, -2, -4}, {-2, -3, 5, -2, -2}, {-1, -2, -2, 5, -1}, {-3, -4,

笑风生 709

从工艺到器件:用Silvaco ATLAS仿真PIN二极管击穿电压的保姆级指南

本文详细介绍了使用Silvaco ATLAS仿真PIN二极管击穿电压的全流程指南,从工艺仿真基础搭建到器件结构构建,再到击穿特性仿真和结果分析。通过Silvaco工具链,工程师可以在设计阶段精准预测器件性能,优化击穿电压,提升研发效率。

weixin_34259816的博客 361

pku1080 Human Gene Functions DP

表示为串1匹配到第i位,串2匹配到第j位时的最大分数 复杂度N2,常数因为写法问题略微大了点 Problem: 1080 User: BPM136 Memory: 732K Time: 16MS Language: G++ Result: Accepted #include #include #include #include #include #include #define LL

BPM136 421

【自然语言处理】【多模态】多模态综述:视觉语言预训练模型

多模态预训练模型综述、模型结构、损失函数、下游任务、CLIP

bqw的博客 7762

基于PCIE8311+FPGA+TMS320F28335 PCIE应用项目开发板PROTEL99设计硬件(原理图+PCB)文件

基于PCIE8311+FPGA+TMS320F28335 PCIE X1应用项目开发板PROTEL99设计硬件(原理图+PCB)文件,Protel 99se 设计的项目工程文件,包括原理图及PCB印制板图,可用Protel或 Altium Designer(AD)软件打开或修改,都已经制板在实际项目中使用,可作为你产品设计的参考。

GJZGRB的博客 581

acm pku 1080 Human Gene Functions的动态规划方法

Human Gene FunctionsDescriptionIt 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. Biologi

uestcshe的专栏 773

用Docker-Compose三节点部署生产级Doris集群:从配置文件到故障转移

本文详细介绍了如何使用Docker-Compose部署一个生产级的三节点Apache Doris集群。内容涵盖从核心架构理解、配置文件编写到集群初始化验证的全过程,并重点讲解了如何实现高可用、数据持久化、健康检查以及故障转移等生产级运维关键点,为中小团队提供了一种在容器化便利性与系统稳定性间取得平衡的可靠部署方案。

kkk56的博客 864

pku1080 Human Gene Functions

题目链接:pku1080     hdu1080    tzc1287 方法:动态规划 思想:本题是最长公共子序列的变种,只是将最长长度换成最大匹配 值,可以用一个二维数组w保存两个字符的匹配度。本题中用一个数组 dp[[i][j]表示第一个字符串的前i个字符与第二个

忠实诚信的专栏 508

SAP RAP学习系列合集介绍

《SAP RAP学习系列合集:从入门到部署的完整指南》摘要: 本文介绍了作者创建的SAP RAP学习系列合集,涵盖RAP开发从基础概念到实战部署的全流程。系列目前包含17篇文章,系统讲解了RAP核心开发技术:从数据建模、UI构建到行为定义(包括并发控制、草稿功能、授权验证等),最后详细演示了应用部署到Fiori Launchpad的两种方案(OP版和ES版)。

DeveloperMrMeng的博客 1512

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

PKU-1080 Human Gene Functions

原题链接 http://poj.org/problem?id=1080 Human Gene Functions   Description It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denote

gk1988的专栏 393

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

pku 1080 Human Gene Functions LCS变形

http://poj.org/problem?id=1080 discuss 里面的解释已经很经典很明白了。http://poj.org/showmessage?message_id=74842 View Code #include <cstdio> #include <cstring> #include <iostream> #define ...

weixin_30732825的博客 107

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

动态规划(acm pku 1080 Human Gene Functions)

<br />http://162.105.81.212/JudgeOnline/problem?id=1080<br /> <br />题目意思是说有两段基因序列,而每两个基因都有一个相似值,在任意匹配之下,求出最大相似值。<br />相似值表格如下,其中'-'代表无基因<br /><br />DP的做法,类似于最长公共子序列,不过这里不是判定相同字符,而是最大的相似值。<br />初始化时注意要先找到超过长度的情况,即对应字符与'-'的相似值<br /> <br /> <br />#include <io

superszy的专栏 249

NASA新处理器比辐射硬化芯片快500倍,星载计算瓶颈被突破?

在辐射环境严苛的航天应用中,芯片设计长期面临可靠性与性能的取舍。传统辐射硬化芯片通过三模冗余、锁步设计等手段保证计算不出错,但代价是资源开销巨大、主频受限,导致星载计算能力远落后于地面。近年来,业界开始转向系统级容错方案:让高性能计算单元充分发挥算力,同时用纠错码、校验重算、看门狗恢复等机制兜底辐射错误。这种思路不仅大幅提升任务级吞吐,也为遥感图像实时处理、星上自主控制、科学数据筛选等场景打开了新空间。性能对比时,需要统一基准、关注辐射指标与工具链完整度,避免被单一跑分误导。NASA团队展示的处理器在测试中

weixin_33782386的博客 478

7种未定式求极限全攻略:从0/0到∞^0一网打尽

高等数学中,极限计算是微积分的基础,而各类未定式往往是初学者最头疼的关卡。未定式的本质是两种趋近趋势的“速度竞赛”,直接代入无法确定结果。从概念出发,理解0/0型、∞/∞型等七种形态的分类逻辑,掌握等价无穷小替换、洛必达法则、泰勒展开等核心工具,是突破极限计算的关键。这些方法不仅是期末和考研的考点,更在函数连续性、导数定义、级数收敛性分析等工程数学场景中广泛应用。通过类型判断、转化变形、工具选择的标准流程,可以将复杂问题化归为熟悉的0/0或∞/∞型,从而高效求解。系统梳理7种未定式的转化思路与实用技巧,并配

weixin_34008933的博客 375

POJ 1080 Human Gene Functions(动态规划)

题目来源:POJ 1080 Human Gene Functions http://acm.pku.edu.cn/JudgeOnline/problem?id=1080 解法类型:动态规划 解题思路: 网上一份解题报告:写的很详细,就此摘来: http://nash250.blog.hexun.com/9794371_d.html 和《算法导论...

weixin_33935777的博客 178

什么是JTAG和SWD接口协议,和各类仿真器

什么是JTAG和SWD接口协议,和各类仿真器

m0_46521000的博客 3394

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
上一篇: pku1062 昂贵的聘礼(Memory Limit Exceeded。。。。。。)
下一篇: pku1609 Tiling Up Blocks (DP题)
zonelight
博客等级 码龄19年 8粉丝 34原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值