Codeforces 747B Mammoth's Genome Decoding(碱基对)
来源:互联网 发布:淘宝盗图技巧不被发现 编辑:程序博客网 时间:2024/06/08 05:52
题意:
给定长度为 n 的只含有 A T C G ? 的字符串,其中的 ? 可以转换为任何一个字母,问是否存在 A T C G碱基个数需要相等。
不存在输出 ===
思路:
简单的模拟题,尴尬的就在于,明明在提交输出的多一个 -> ?
AC CODE:
#include<stdio.h>#include<cstring>#include<cmath>#include<algorithm>#define HardBoy main()#define ForMyLove return 0;using namespace std;const int MYDD = 1103;int HardBoy {int a = 0, g = 0, c = 0, t = 0, n; char s[MYDD];scanf("%d %s", &n, s);if(n%4 != 0){puts("===");} else {for(int j = 0; j < n; j++){if(s[j] == '?') continue;if(s[j] == 'A') a++;else if(s[j] == 'C') c++;else if(s[j] == 'G') g++;else if(s[j] == 'T') t++;} int v = n/4;if(c > v || a > v || g > v || t > v){puts("===");} else {for(int j = 0; j < n; j++){if(s[j] == '?'){if(a < v){s[j] = 'A';a++;} else if(c < v){s[j] = 'C';c++;} else if(g < v){s[j] = 'G';g++;} else if(t < v){s[j] = 'T';t++;}}}printf("%s\n", s);} }ForMyLove}
所谓 WA CODE:
#include<stdio.h>#include<cstring>#include<cmath>#include<algorithm>#define HardBoy main()#define ForMyLove return 0;using namespace std;const int MYDD = 1103;int HardBoy {int a[4] ={0}, b[4] ={0}, n;char s[MYDD], zi[] = {"ACGT"};scanf("%d %s", &n, s); if(n % 4){puts("===");} else {for(int j = 0; j < n; j ++){if(s[j] == 'A') a[0]++;if(s[j] == 'C') a[1]++;if(s[j] == 'G') a[2]++;if(s[j] == 'T') a[3]++;}for(int j = 0; j < 4; j++){b[j] = n/4 - a[j];if(b[j] < 0){puts("===");return 0;}}for(int i = 0; i < n; i++){while(s[i] == '?'){for(int j = 0; j < 4; j++){if(b[j] <= 0) continue; printf("%c", zi[j]);b[j]--;i++;break;}} printf("%c", s[i]); }}ForMyLove}/*8????????ACCATTGG*/
0 0
- Codeforces 747B Mammoth's Genome Decoding(碱基对)
- 【codeforces 747B】Mammoth's Genome Decoding
- CodeForces 747B Mammoth's Genome Decoding
- 【58.33%】【codeforces 747B】Mammoth's Genome Decoding
- 【Codeforces 747B Mammoth's Genome Decoding】+ 构造
- 747B Mammoth's Genome Decoding
- Mammoth's Genome Decoding CodeForces
- Codeforces Round #387 (Div. 2) B. Mammoth's Genome Decoding
- Codeforces Round #387 (Div. 2)B. Mammoth's Genome Decoding(水题)
- Codeforces Round #387 (Div. 2)B. Mammoth's Genome Decoding(简单模拟)
- Codeforces Round #387(Div. 2)B. Mammoth's Genome Decoding【模拟】
- 【每日一题(8)】Mammoth's Genome Decoding CodeForces
- Mammoth's Genome Decoding,测英语,测手速,测网速
- CodeForces 222E Decoding Genome
- CodeForces 746B Decoding
- 746 B. Decoding codeforces
- 【codeforces 746B】 Decoding
- CodeForces 746B Decoding
- Delphi“尚未调用CoInitialize”解决方法
- Java架构师
- CVPR 2016-12-13
- ubuntu12.10上安装wine遇到的一些问题
- Codeforces Round #387 (Div. 2) E. Comments
- Codeforces 747B Mammoth's Genome Decoding(碱基对)
- Windows或Linux系统中备份和恢复MongoDB数据的教程
- 对输入的字符串中C关键词的查找统计。
- 数据结构 邻接矩阵的BFS DFS
- 自定义集合
- 2016.12.12 锋利的jQueryCH11--性能优化和技巧
- ajax异步刷新邂逅了你—innerHTML
- HDU 2539 点球大战
- 翻译《有关编程、重构及其他的终极问题?》——11.不要试图把尽量多的操作符放到一行代码里