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 ...
随机推荐
- 获取电脑名和IP地址
private string GetHostNameAndIP( bool isv4Orv6) { string HostName = Dns.GetHostN ...
- selenium 常见问题之 nknown error: call function result missing ‘value’
运行时候出现错误提示如下: 出现该问题原因:chrome浏览器自动升级.导致和chromedriver支持的版本不匹配. 解决方案有两种(本人采用的是第一种方式解决办法.): 1.下载和当前使用的ch ...
- Mysql+php报错原因
SQL syntax --语法错误,看near,错误会在near后引号中的内容 的附近 Table/Database....... dosen't existes ---表/库(库名/表名) 不存在 ...
- DOM修改元素的方法总结
今天我们要谈谈DOM元素的修改(包括修改内容,属性,样式).修改内容的方法----3种:elem.innerHTML:获取或设置元素开始标签到结束标签之间的原始HTML代码片段:elem.textCo ...
- iOS 9 学习系列:Split Screen Multitasking
http://www.cocoachina.com/ios/20151010/13601.html iOS 9 的一个重大变化就是增加了多任务,这个多任务允许用户在屏幕上同时运行多个 app.有两种形 ...
- python 初始化init方法
- PersistGate轻松几步让Redux实现数据持久化
在开发的过程中,数据用redux管理,觉得希望将数据持久化保存,也就是说当用户下一次打开app或网站的时候,我们希望浏览器/APP自动加载出上次的数据,怎么办?有没有一个
- Guitar
nuomi N3380614240045529680 N3380614240167717364 1404679948665073 装修风格: http://www.douban.com/group/t ...
- srand函数
srand函数是随机数发生器的初始化函数. 原型: void srand(unsigned seed); 用法:它需要提供一个种子,这个种子会对应一个随机数,如果使用相同的种子后面的rand()函数会 ...
- MUI - myStorage在ios safari无痕浏览模式下的解决方案
myStorage在ios safari无痕浏览模式下的解决方案 今天看到了这个帖子LocalStorage 在 Private Browsing 下的一个限制, 吓尿了,如果用户开启了无痕浏览,ap ...