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 ...
随机推荐
- oracle定时执行计划任务
show parameter job_queue_processes; alter system set job_queue_processes=10; 1,创建测试表 create table jo ...
- thenjs的应用
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Andrew Ng Machine learning Introduction
1. 机器学习的定义:Machine learning is programming computers to optimize a performance criterion(优化性能标准) usi ...
- 魔兽世界---屠夫(Just a Hook)
Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- iOS_词典阵列 按key分组和排序
// // main.m // SortGroup // // Created by beyond on 14-10-26. // Copyright (c) 2014年 beyond.com All ...
- BZOJ 2716 Violet 3 天使玩偶 CDQ分治
题目大意:初始给定平面上的一个点集.提供两种操作: 1.将一个点增加点集 2.查询距离一个点最小的曼哈顿距离 K-D树是啥...不会写... 我仅仅会CDQ分治 对于一个询问,查询的点与这个点的位置关 ...
- 简单C#文字转语音
跟着微软走妥妥的,C#文字转语音有很多参数我就不说了,毕竟我也是初学者.跟大家分享最简单的方法,要好的效果得自己琢磨喽: 先添加引用System.Speech程序集: using System; us ...
- 使用jsp标签和java资源管理实现jsp支持多语言
1.编写一个Serverlet并设置服务器启动是初始化该Servlet,并在初始化方法中实现对java的资源加载: DispatcherServlet.java package mypack; imp ...
- 小鱼提问1 类中嵌套public修饰的枚举,外部访问的时候却只能Class.Enum这样访问,这是为何?
/// <summary> /// 常量等定义 /// </summary> public class General { /// <summary> /// 文件 ...
- Hive 入门(转)
#创建表人信息表 person(String name,int age) hive> create table person(name STRING,age INT)ROW FORMAT DE ...