Blue Jeans
来源:互联网 发布:最优化方法唐焕文答案 编辑:程序博客网 时间:2024/04/29 13:36
Description
The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth was populated.
As an IBM researcher, you have been tasked with writing a program that will find commonalities amongst given snippets of DNA that can be correlated with individual survey information to identify new genetic markers.
A DNA base sequence is noted by listing the nitrogen bases in the order in which they are found in the molecule. There are four bases: adenine (A), thymine (T), guanine (G), and cytosine (C). A 6-base DNA sequence could be represented as TAGACC.
Given a set of DNA base sequences, determine the longest series of bases that occurs in all of the sequences.
As an IBM researcher, you have been tasked with writing a program that will find commonalities amongst given snippets of DNA that can be correlated with individual survey information to identify new genetic markers.
A DNA base sequence is noted by listing the nitrogen bases in the order in which they are found in the molecule. There are four bases: adenine (A), thymine (T), guanine (G), and cytosine (C). A 6-base DNA sequence could be represented as TAGACC.
Given a set of DNA base sequences, determine the longest series of bases that occurs in all of the sequences.
Input
Input to this problem will begin with a line containing a single integer n indicating the number of datasets. Each dataset consists of the following components:
- A single positive integer m (2 <= m <= 10) indicating the number of base sequences in this dataset.
- m lines each containing a single base sequence consisting of 60 bases.
Output
For each dataset in the input, output the longest base subsequence common to all of the given base sequences. If the longest common subsequence is less than three bases in length, display the string "no significant commonalities" instead. If multiple subsequences of the same longest length exist, output only the subsequence that comes first in alphabetical order.
Sample Input
32GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATAGATACTAGATACTAGATACTAGATACTAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAAGATACCAGATACCAGATACCAGATACCAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA3CATCATCATCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACATCATCATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACATCATCATTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
Sample Output
no significant commonalitiesAGATACCATCATCAT代码:#include <iostream>#include <cstring>using namespace std;int main(){ int n; cin>>n; while(n--) { int m,i; char p[15][65]; cin>>m; for(i=0;i<m;i++) cin>>p[i]; int len; char ans[65]; len=0; for(i=0;i<strlen(p[0]);i++) for(int j=i+2;j<strlen(p[0]);j++) { char s[65]; strncpy(s,p[0]+i,j-i+1); s[j-i+1]='\0'; bool ok=true; for(int k=1;ok&&k<m;k++) if(strstr(p[k],s)==NULL) ok=false; if(ok&&(j-i+1>len||j-i+1==len&&strcmp(ans,s)>0))\ { len=j-i+1; strcpy(ans,s); } } if(len<3) cout<<"no significant commonalities"<<endl; else cout<<ans<<endl; } return 0;}
0 0
- Blue Jeans
- Blue Jeans
- Blue Jeans
- Blue Jeans
- Blue Jeans
- BLUE Jeans
- poj3080 blue Jeans
- PKU 3080 Blue Jeans
- 3080 Blue Jeans//KMP
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- (kmp) Blue Jeans (3080)
- poj3080 Blue Jeans-------KMP
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- Blue Jeans poj3080
- POJ 3080 Blue Jeans
- [DP] POJ 1163 The Triangle
- android wifi p2p 通信
- 有关线程池
- Python 通过格式符打印
- 各坐标的转换:
- Blue Jeans
- GDB 反向调试(Reverse Debugging)
- 在linux下如何安装python?
- 直连线和交叉线----网线的小知识
- 2014 BUPT 新生排位赛03
- joyent 云计算服务公司
- hdu 1394 线段树单点更新
- unity3d射线的原理用法以及一个利用射线实现简单拾取的小例子
- 黑马程序员【Java多线程机制和用法】