UVa1368/ZOJ3132 DNA Consensus String
#include <stdio.h>
#include <string.h>
int main()
{
int a[4][1000]; // A/C/G/T在每列中出现的次数
char c, x;
char bas[4] = { 'A', 'C', 'G', 'T' };
int T, m, n, i, j, k, dist;
scanf("%d", &T);
while (T--)
{
scanf("%d %d\n", &m, &n);
memset(a, 0, sizeof(a));
for (i = 0; i < m; ++i)
{
for (j = 0; j < n; ++j)
{
c = getchar();
if (c == 'A')
++a[0][j];
else if (c == 'C')
++a[1][j];
else if (c == 'G')
++a[2][j];
else
++a[3][j];
}
getchar();
}
dist = 0;
for (j = 0; j < n; ++j)
{
k = -1;
for (i = 0; i < 4; ++i)
{
if (a[i][j] > k)
{
k = a[i][j];
x = bas[i];
}
}
for (i = 0; i < 4; ++i)
{
if (bas[i] != x)
dist += a[i][j];
}
putchar(x);
}
printf("\n%d\n", dist);
}
return 0;
}
UVa1368/ZOJ3132 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 ...
- 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 ...
- DNA序列 (DNA Consensus String,ACM/ICPC Seoul 2006,UVa1368
题目描述:算法竞赛入门经典习题3-7 题目思路:每列出现最多的距离即最短 #include <stdio.h> #include <string.h> int main(int ...
- UVA-1368 DNA Consensus String(思路)
题目: 链接 题意: 题目虽然比较长,但读完之后题目的思路还是比较容易想出来的. 给出m个长度为n的字符串(只包含‘A’.‘T’.‘G’.‘C’),我们的任务是得出一个字符串,要求这个字符串与给出的m ...
- uva 1368 DNA Consensus String
这道题挺简单的,刚开始理解错误,以为是从已有的字符串里面求最短的距离,后面才发现是求一个到所有字符串最小距离的字符串,因为这样的字符串可能有多个,所以最后取最小字典序的字符串. 我的思路就是求每一列每 ...
- uvalive 3602 DNA Consensus String
https://vjudge.net/problem/UVALive-3602 题意: 给定m个长度均为n的DNA序列,求一个DNA序列,使得它到所有的DNA序列的汉明距离最短,若有多个解则输出字典序 ...
- 【每日一题】UVA - 1368 DNA Consensus String 字符串+贪心+阅读题
https://cn.vjudge.net/problem/UVA-1368 二维的hamming距离算法: For binary strings a and b the Hamming distan ...
随机推荐
- git操作标签
操作标签 如果标签打错了,也可以删除: $ git tag -d v0.1 Deleted tag 'v0.1' (was e078af9) 因为创建的标签都只存储在本地,不会自动推送到远程.所以,打 ...
- Exec sql/c
Exec sql/c 利用高级语言的过程性结构来弥补SQL语言实现复杂应用方面的不足. 嵌入SQL的高级语言称为主语言或宿主语言. 在混合编程中,SQL语句负责操作数据库,高级语言语句负责控制程序流程 ...
- poj2583---Series Determination
#include <stdio.h> #include <stdlib.h> int main() { int x,y,z,a,b,c; while(scanf("% ...
- ntpd和ntpdate的区别
之前配置ntpd的时候搜到一句话,印象很深刻,也觉得很有标题党的效果,就借鉴为标题了:“我认为有几种人是必须不招聘/裁掉的: 1 用ntpdate代替ntpd的人”但具体原因不太懂,总觉得还是用ntp ...
- How to Type(dp)
How to Type Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- python手记(36)
#!/usr/bin/env python #-*- coding: utf-8 -*- #code:myhaspl@qq.com import cv2 import numpy as np fn=& ...
- JSP简单练习-获取表单数据
在JSP中,server端程序与client交互最经常使用的方法就是採用表单提交数据.表单提交的方法主要有两种,一种是get方法.还有一种是post方法.两者最大的差别:使用get方法提交的数据会显示 ...
- 部署WSP出现错误—已在此服务器场中安装ID为XXXXX的功能
stsadm -o deploysolution -name ***.wsp -immediate -allowGacDeployment -url http://*** -force
- NET,ASP.NET,C#,WinFrom之间的联系与区别
1:C#是编程语言(静态,强类型).类似中文.德文.英文这样. 2:.NET是一个平台(可承载多个编程语言,比如C# C++.net J# VB.Net), 但是都是运行在.net Fra ...
- java堆溢出的小栗子
package com.xiaoysec.test; import java.util.ArrayList; import java.util.List; /** *VM Args:-verbose: ...