zoukankan      html  css  js  c++  java
  • LA 3602 DNA Consensus String

    LA_3602

        由于每一位都是独立的,我们依次处理每一位即可。对每一位找到出现次数最多的字符,如果次数相同的话,就找字典序较小的那个。

    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    #define MAXN 60
    #define MAXL 1010
    int N, L;
    char a[MAXN][MAXL], id[128], ch[4] = {'A', 'C', 'G', 'T'};
    void input()
    {
        scanf("%d%d", &N, &L);
        for(int i = 0; i < N; i ++) scanf("%s", a[i]);
    }
    int process(int i)
    {
        int h[4] = {0}, k, n = -1;
        for(int j = 0; j < N; j ++) ++ h[id[a[j][i]]];
        for(int j = 0; j < 4; j ++)
            if(h[j] > n) n = h[j], k = j;
        std::cout << ch[k];
        return N - n;
    }
    int main()
    {
        int t;
        scanf("%d", &t);
        id['A'] = 0, id['C'] = 1, id['G'] = 2, id['T'] = 3;
        while(t --)
        {
            input();
            int n = 0;
            for(int i = 0; i < L; i ++) n += process(i);
            std::cout << std::endl << n << std::endl;
        }
        return 0;
    }
  • 相关阅读:
    fpga不错的源代码下载地址
    iverilog命令选项解释
    altera官方视频教程下载地址
    niosII EDS和QuartusII安装心得体会
    FPGA的JTAG口很脆弱?
    poj2379
    poj2472
    poj2935
    poj3366
    poj1493
  • 原文地址:https://www.cnblogs.com/staginner/p/2760217.html
Copyright © 2011-2022 走看看