UVA1368】的更多相关文章

书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 都是<算法竞赛入门经典(第二版)>的题目,标题上没写(第二版) 题目:算法竞赛入门经典 3-7/UVa1368:DNA Consensus String 代码: //UVa1368 - DNA Consensus String #include<iostream> using namespace std; #define MAX_M 52 #define MAX_N 1005 char DNA[MAX…
用一个二维数组装m个字符串,然后用一个数组装每个字符串的hamming距离.找到最小的hanming距离即可 #include<stdio.h> #include<string.h> //比较两个字符串有多少个元素不同 int hamming(char s1[],char s2[],int n){ ; ;i<n;i++) if(s1[i] != s2[i]) count++; return count; } int main(){ int m,n; ][]; ]; int c…
<tex2html_verbatim_mark> Figure 1. DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It consists of four different nucleotides, namely Adenine, Thymine, Guanine, and Cytosine as shown in Figure 1. If we represent a…
#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(&…
题目描述:算法竞赛入门经典习题3-7 题目思路:每列出现最多的距离即最短 #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { int m,n ; scanf("%d%d",&m,&n) ; ][n+] ; ;i<m;i++) scanf("%s",&c[i]) ; //for(int i=0;i<m;i++) /…
题目: 链接 题意: 题目虽然比较长,但读完之后题目的思路还是比较容易想出来的. 给出m个长度为n的字符串(只包含‘A’.‘T’.‘G’.‘C’),我们的任务是得出一个字符串,要求这个字符串与给出的m个字符串的汉明距离的和最小,输出这个字符串和最小的汉明距离和. 如果有多个符合题意的字符串,就输出字典序最小的那个字符串. 思路: 1.首先给出汉明距离的定义: 汉明距离表示相同长度的字对应位不同的数量. 例如: 10100和11000的汉明距离就是2. 2.对m个字符串的每一位分别统计‘A’.‘T…
https://cn.vjudge.net/problem/UVA-1368 二维的hamming距离算法: For binary strings a and b the Hamming distance is equal to the number of ones (population count) in a XOR b. int hamming_distance(unsigned x, unsigned y) { ; unsigned val = x ^ y; // Count the n…
题目链接:https://vjudge.net/problem/UVA-1368 题意:给出一组字符串,求出一组串,使与其他不同的点的和最小 题解:这个题就是一个点一个点求,利用桶排序,求出最多点数目的集合,如果点数相同,则按字母序最小的点为准 ac代码 #include<iostream>#include<cstdio>#include<cstring>using namespace std;char ch[60][1100],ans[1100];int main()…