LRJ 3-7
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> int main()
{
int T;
int m, n;
char dna[][]; // 4 <= m <= 50, 4 <= n <= 1000 scanf("%d", &T);
while (T--) {
scanf("%d%d", &m, &n);
for (int i = ; i < m; i++) {
scanf("%s", dna[i]);
}
/*
for (int i = 0; i < m; i++) {
printf("%s\n", dna[i]);
}
*/
char ans[]; // 4 <= n <= 1000
int cnt[]; // count for 'A', 'C', 'G', 'T' in a column
int max;
char maxChar; // scan each column, select the character which occurs the most time,
// if there is a tie, select the lexicographically smaller one
for (int j = ; j < n; j++){ cnt[] = cnt[] = cnt[] = cnt[] = max = ; for (int i = ; i < m; i++){
switch (dna[i][j]){
case 'A': {
cnt[]++;
if (cnt[] > max || (cnt[] == max && maxChar > 'A')){
max = cnt[];
maxChar = 'A';
}
break;
}
case 'C': {
cnt[]++;
if (cnt[] > max || (cnt[] == max && maxChar > 'C')){
max = cnt[];
maxChar = 'C';
}
break;
}
case 'G': {
cnt[]++;
if (cnt[] > max || (cnt[] == max && maxChar > 'G')){
max = cnt[];
maxChar = 'G';
}
break;
}
case 'T': {
cnt[]++;
if (cnt[] > max){
max = cnt[];
maxChar = 'T';
}
break;
}
} } ans[j] = maxChar;
}
ans[n] = '\0';
printf("%s\n", ans); // count the total Hamming distance
int h_dis = ;
for (int i = ; i < m; i++){
for (int j = ; j < n; j++){
if (dna[i][j] != ans[j])
h_dis++;
}
}
printf("%d\n", h_dis);
} return ;
}
LRJ 3-7的更多相关文章
- lrj计算几何模板
整理了一下大白书上的计算几何模板. #include <cstdio> #include <algorithm> #include <cmath> #include ...
- 倒水问题(Fill,UVA 10603) lrj白书 p202
看着lrj的代码自己敲了一遍,还没调试成功.... 有时间再进行完善 /* 状态start到各个状态u1,u2,u3..... 的倒水量分别为u1.dist,u2.dist,u3.dist.... * ...
- LRJ入门经典-0907万圣节的小L306
原题 LRJ入门经典-0907万圣节的小L306 难度级别:B: 运行时间限制:1000ms: 运行空间限制:256000KB: 代码长度限制:2000000B 试题描述 今天是万圣节,小L同学开始了 ...
- LRJ入门经典-0906最短公共父串305
原题 LRJ入门经典-0906最短公共父串305 难度级别:B: 运行时间限制:1000ms: 运行空间限制:256000KB: 代码长度限制:2000000B 试题描述 给定字符串A和字符串B,要求 ...
- LRJ入门经典-0905邮票和信封305
原题 LRJ入门经典-0905邮票和信封305 难度级别:B: 运行时间限制:1000ms: 运行空间限制:256000KB: 代码长度限制:2000000B 试题描述 假定一张信封最多贴5张邮票,如 ...
- LRJ入门经典-0903切蛋糕305
原题 LRJ入门经典-0903切蛋糕305 难度级别:B: 运行时间限制:1000ms: 运行空间限制:256000KB: 代码长度限制:2000000B 试题描述 如图所示有一个矩形蛋糕,上面划分成 ...
- // 62.是否有利润奖--lrj private boolean isProfitsAward; // 63.利润奖--lrj_price private String profitsAward;
// 62.是否有利润奖--lrj private boolean isProfitsAward; // 63.利润奖--lrj_price private String profitsAward; ...
- 第五章第二例题关于Vector(LRJ)
vector(动态数组)(粘) 一.概述 vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库.vector是一个容器,它能够存放各种类型的对象,简 ...
- 第四章第四个例题(LRJ)
半年了,最起码的编程能力也谈不上啊,思维神马就更不不敢说了. 互联网时代讲求效率,走得慢和不走没有区别了. The war is on. (buhuidetiduokanduodajibianyehu ...
- 强连通分量(LRJ训练指南)
#include <iostream> #include <queue> #include <string> #include <cstdio> #in ...
随机推荐
- CSS-画三角
要实现三角的效果有很多方法: 例如下面的页面就需要三角: 其中, <!DOCTYPE html> <html lang="en"> <head> ...
- python 从数据库取回来的数据中文显示为乱码
问题:从数据库取回来的数据,中文显示为乱码. 解决办法: 此处要指定charset为utf-8(一般数据库编码都是utf8),否则读取出的中文会乱码
- hdu 4722 Good Numbers( 数位dp入门)
Good Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- Codeforces Round #416 (Div. 2) A. Vladik and Courtesy【思维/模拟】
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- mysql的三种连接方式
SQL的三种连接方式分为:左外连接.右外连接.内连接,专业术语分别为:LEFT JOIN.RIGHT JOING.INNER JOIN 内连接INNER JOIN:使用比较运算符来根据指定的连接的每个 ...
- DIV元素垂直居中的分析与实现
首先,对于需要垂直居中的元素常规居中处理 margin: 0 auto; 接下来要设置div的祖先元素的宽高为100%, 在默认的设置中他们都为0: html, body { width: %; he ...
- 洛谷P1248 加工生产调度
流水作业调度问题 有\(N\)个作业要在两台机器\(M_1\)和\(M_2\)组成的流水线上完成加工.每个作业\(i\)都必须先花时间\(a_i\)在\(M_1\)上加工,然后花时间\(b_i\)在\ ...
- concurrent模块
concurrent包 concurrent.futrues模块 3.2版本引入 异步并行任务模块,提供一个高级的异步可执行的便利接口. 提供了两个池执行器 ThreadPoolExecutor异步调 ...
- docker出现如下错误:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
在docker中配置deepo时出现了错误: 在出现这个错误之前,我是先用如下命令查看NVIDIA-docker是否安装成功. docker run --runtime=nvidia --rm nvi ...
- 洛谷P2062 分队问题
这是一道普及/提高- 然后你懂的,贪心扫一遍就可以了. 不懂提交人数那么少. //Serene #include<algorithm> #include<iostream> ...