LA 3602 - DNA Consensus String 枚举
题目大意:
给定m个长度均为n的DNA序列,使其(那个啥序列来着,噢)Hamming,(好吧,这单词我复制的T T)序列尽量短,Hamming指的是字符不同位置的个数。(For example, assume we are given the two strings ``AGCAT" and ``GGAAT." The Hamming distance of these two strings is 2 because the 1st and the 3rd characters of the two strings
are different. `AGCAT和GGAAT 的Hamming为2,因为第一和第三字母不一样)如果有多解,取字典序小的。
数据量小,可以直接枚举。.然后就没有然后了。@。@
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1000+10;
char a[50+10][MAXN],ans[MAXN];
int A,C,G,T,diff;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
diff=0;
int n,m;
scanf("%d%d",&m,&n);
for(int i=0;i<m;i++)
scanf("%s",a[i]);
for(int i=0;i<n;i++)
{
A=G=C=T=0;
for(int j=0;j<m;j++)
{
switch(a[j][i])
{
case 'A':A++;break;
case 'C':C++;break;
case 'G':G++;break;
case 'T':T++;break;
}
}
int MAX=0;
MAX=max( max (max (max(MAX,A) ,C) ,G) ,T); if(MAX==A) { diff=diff+C+G+T; ans[i]='A'; }
else if(MAX==C) { diff=diff+A+G+T; ans[i]='C'; }
else if(MAX==G) { diff=diff+C+A+T; ans[i]='G'; }
else if(MAX==T) { diff=diff+C+G+A; ans[i]='T'; }
}
ans[n]='\0'; //注意末尾填结束符,除非你逐个字符输出
printf("%s\n%d\n",ans,diff);
}
}
LA 3602 - DNA Consensus String 枚举的更多相关文章
- 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...
- LA 3602 DNA Consensus String (暴力枚举)
题意:给定m个长度为n的DNA序列,求一个最短的DNA序列,使得总Hamming距离最小. Hamming距离等于字符不同的位置个数. 析:看到这个题,我的第一感觉是算时间复杂度,好小,没事,完全可以 ...
- LA 3602 DNA Consensus String
最近审题老是一错再错,Orz 题目中说求一个Hamming值总和最小的字符串,而不是从所给字符中找一个最小的 这样的话,我们逐列处理,所求字符串当前位置的字符应该是该列中出现次数最多其次ASCII值最 ...
- uvalive 3602 DNA Consensus String
https://vjudge.net/problem/UVALive-3602 题意: 给定m个长度均为n的DNA序列,求一个DNA序列,使得它到所有的DNA序列的汉明距离最短,若有多个解则输出字典序 ...
- UVa 3602 - DNA Consensus String 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- uva1368 DNA Consensus String
<tex2html_verbatim_mark> Figure 1. DNA (Deoxyribonucleic Acid) is the molecule which contains ...
- DNA Consensus String
题目(中英对照): DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It co ...
- 紫书第三章训练1 E - DNA Consensus String
DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It consists of ...
- uva 1368 DNA Consensus String
这道题挺简单的,刚开始理解错误,以为是从已有的字符串里面求最短的距离,后面才发现是求一个到所有字符串最小距离的字符串,因为这样的字符串可能有多个,所以最后取最小字典序的字符串. 我的思路就是求每一列每 ...
随机推荐
- jQuery07源码 (3803 , 4299) attr() prop() val() addClass()等 : 对元素属性的操作
var nodeHook, boolHook, rclass = /[\t\r\n\f]/g, rreturn = /\r/g, rfocusable = /^(?:input|select|text ...
- Socket编程中的强制关闭与优雅关闭及相关socket选项
以下描述主要是针对windows平台下的TCP socket而言. 首先需要区分一下关闭socket和关闭TCP连接的区别,关闭TCP连接是指TCP协议层的东西,就是两个TCP端之间交换了一些协议包( ...
- 33.IDEA + maven]在IDEA中打开一个maven项目,resolve完依赖后,缺少部分jar包问题
转自:https://www.cnblogs.com/zazalu/p/7649590.html [注意]作者只是对使用过程中遇到的问题提出了一个解决方案,但是本人在编写此解决方案文章的时候,对mav ...
- git --- ! [rejected] master -> master (non-fast-forward)
如何解决failed to push some refs to git Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push ...
- Domino系统从UNIX平台到windows平台的迁移及备份
单位机房的一台服务机器到折旧期了,换成了新购IBM机器X3950,而且都预装了windows 2003 server 标准版,所以只有把以前在Unix平台下跑的OA系统迁移到新的windows 200 ...
- Objective-C ,ios,iphone开发基础:UIAlertView使用详解
UIAlertView使用详解 Ios中为我们提供了一个用来弹出提示框的类 UIAlertView,他类似于javascript中的alert 和c#中的MessageBox(); UIAlertVi ...
- Windows学习总结(5)——【IIS建站】Windows10怎么打开站点服务?
从Windows8开始,界面发生了很大的变动,再到Windows10,仍然有不小的变动,鉴于以后Windows10会成为主流,我们姑且介绍下Windows10建站的方法,虽然它并不是专业的服务器系统, ...
- CODEVS——T2744 养鱼喂妹纸
http://codevs.cn/problem/2744/ 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond 题解 查看运行结果 题目描述 Descr ...
- Centos6.4安装opennebula
Centos6.4安装opennebula #安装163源 http://mirrors.163.com/.help/CentOS6-Base-163.repo #安装epel源 wget http: ...
- 15.Node.js REPL(交互式解释器)
转自:http://www.runoob.com/nodejs/nodejs-tutorial.html Node.js REPL(Read Eval Print Loop:交互式解释器) 表示一个电 ...