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(&…
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r++; printf("Case %d: %d\n",++kas,r); } ; } LA 3602 DNA Consensus String 贪心构造,每一位上选出现次数最多的. #include<bits/stdc++.h> using namespace std; ,ma…
<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…
题目(中英对照): 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 nucleotide by its initial…
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 nucleotide by its initial character…
题目描述:算法竞赛入门经典习题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…
这道题挺简单的,刚开始理解错误,以为是从已有的字符串里面求最短的距离,后面才发现是求一个到所有字符串最小距离的字符串,因为这样的字符串可能有多个,所以最后取最小字典序的字符串. 我的思路就是求每一列每个基因A.C.G.T的数量,找到最大值,最大值可能不止一个,但是锁定字典序最小的那个为所求字符串当前列的值,求解实例如下所示 TATGATACTAAGCTACAAAGATCCTGAGATACTAAGATGT 对于上述字符串,第一列A,C,G,T的值分别为1,0,0,4,可见最大值为4,说明当前列到每…
https://vjudge.net/problem/UVALive-3602 题意: 给定m个长度均为n的DNA序列,求一个DNA序列,使得它到所有的DNA序列的汉明距离最短,若有多个解则输出字典序最小的解. ps:汉明距离指的是两个等长字符串中字符不同的位置的个数. 思路: 贪心原则,记录每一个位置上哪个字母出现的次数最多,如果有相同的就取字典序最小的那个,然后放进答案就可以了. 代码: #include <iostream> #include <string> #includ…
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…