• UVa 3602


    题目

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1603


    题意

    问使m个n长碱基序列汉明码最小的序列

    思路

    明显,取最频繁的

    代码

    #include <algorithm>
    #include <cassert>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <map>
    #include <queue>
    #include <set>
    #include <string>
    #include <tuple>
    #define LOCAL_DEBUG
    using namespace std;
    typedef pair<int, int> MyPair;
    int cnt[1000][256];
    
    int main() {
    #ifdef LOCAL_DEBUG
        freopen("C:\Users\Iris\source\repos\ACM\ACM\input.txt", "r", stdin);
        //freopen("C:\Users\Iris\source\repos\ACM\ACM\output.txt", "w", stdout);
    #endif // LOCAL_DEBUG
        int T;
        int m, n;
        cin >> T;
        for (int ti = 1;cin>>m>>n; ti++) {
            string tmp;
            memset(cnt, 0, sizeof cnt);
            for (int i = 0; i < m; i++) {
                cin >> tmp;
                for (int j = 0; j < n; j++) {
                    cnt[j][tmp[j]]++;
                }
            }
            int ans = 0;
            for (int j = 0; j < n; j++) {
                char anschar = 'A';
                for (char ch : {'A', 'C', 'G', 'T'}) {
                    if (cnt[j][ch] > cnt[j][anschar]) {
                        anschar = ch;
                    }
                }
                putchar(anschar);
                ans += m - cnt[j][anschar];
            }
            putchar('
    ');
            printf("%d
    ", ans);
        }
    
        return 0;
    }
    View Code
  • 相关阅读:
    知识要点
    SQL语法(包括建库、建表、建视图、查询、增加、删除、修改)
    SQL语句(建库、建表、修改语句)
    比较好的电影网站
    crud创建,修改,删除,查询
    代码创建与操作数据库
    数据库
    数组与集合
    结构体
    类的运用
  • 原文地址:https://www.cnblogs.com/xuesu/p/10462837.html
Copyright © 2020-2023  润新知