DNA Consensus String UVA - 1368
2017-04-03 12:47
387 查看
问题类型:字符串,搜索。
03pie’s solution for [UVA-1368]:
03pie’s solution for [UVA-1368]:
#include<cstdio> #include<iostream> #include<sstream> #include<cstdlib> #include<cmath> #include<cctype>//isalpha(),isdigit(),issprint()|toupper(),tolower() #include<string>//strlen() #include<cstring> #include<algorithm> #include<stack> #include<queue> #include<set> #include<map> #include<ctime> #include<vector> #include<fstream> #include<list> using namespace std; #define ms(s) memset(s,0,sizeof(s))typedef unsigned long long ULL; typedef long long LL; const double PI = 3.141592653589; const int INF = 0x3fffffff; #define maxn 1000 char c(int i) { if(i==0) return 'A'; if(i==1) return 'C'; if(i==2) return 'G'; if(i==3) return 'T'; } char DNAs[maxn][maxn]; int main(){ // freopen("F://inp.txt","r",stdin); int T; scanf("%d",&T); while(T--) { int count[4]; memset(count,0,sizeof(count)); int row,col; scanf("%d%d",&row,&col); char ans[col]; int anscut=0; getchar(); for(int i=0;i<row;i++) { gets(DNAs[i]); } for(int j=0;j<col;j++) { for(int i=0;i<row;i++) { if(DNAs[i][j]=='A') count[0]++; else if(DNAs[i][j]=='C') count[1]++; else if(DNAs[i][j]=='G') count[2]++; else if(DNAs[i][j]=='T') count[3]++; } int max=count[0],tmp=0; for(int k=1;k<4;k++) { if(count[k]>max) { max=count[k]; tmp=k; } } ans[j]=c(tmp); anscut+=(row-max); memset(count,0,sizeof(count)); } for(int i=0;i<col;i++) printf("%c",ans[i]); printf("\n%d\n",anscut); } return 0; }
相关文章推荐
- UVa 1368 - DNA Consensus String
- UVA - 1368 DNA Consensus String :简单字符串处理
- (uva)1368 DNA Consensus String(map)
- UVA1368 - DNA Consensus String
- UVA 1368-DNA Consensus String
- UVa 1368 - DNA Consensus String
- DNA序列(DNA Consensus String, ACM/ICPC seoul 2006, UVa 1368)
- 算法竞赛入门经典(紫书)第三章——DNA Consensus String UVA-1368
- UVA - 1368 DNA Consensus String
- zoj3132(uva1368) DNA Consensus String(水)
- uva 1368 - DNA Consensus String(贪心)
- 算法竞赛入门经典第三章3-7 DNA Consensus String UVA - 1368
- UVA - 1368 DNA Consensus String
- 3-7 DNA序列(DNA Consensus String, ACM/ICPC Seoul 2006, UVa1368)
- 详细解答Uva - 1368 - DNA Consensus String
- UVA 1368 - DNA Consensus String(贪心)
- uva1368 - DNA Consensus String
- UVA 1368 - DNA Consensus String
- DNA序列(DNA Consensus String, UVa 1368)算法
- UVa:1368 DNA Consensus String