poj 3080 Blue Jeans
来源:互联网 发布:合肥行知学校是重点吗 编辑:程序博客网 时间:2024/06/10 16:02
题目链接:点击打开链接
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
题目大意:给出n个DNA序列字符串,问最长相同的字串,相同子串的长度<3输出:
no significant commonalities
else 输出该子串
直接暴力
<span style="font-size:18px;">#include <iostream>#include<cstring>using namespace std;char str[20][100];char a[100];char b[100];int main(){ int n; int t; cin>>t; while(t--) { cin>>n; for(int i=1;i<=n;i++) { cin>>str[i]; } memset(b,'\0',sizeof(b)); int flag=0; for(int i=1;i<=60;i++) { for(int j=0;j<=60-i;j++)//i是从1开始的 { int len=0; for(int k=j;;k++) { a[len++]=str[1][k]; if(i==len)break; } a[len]='\0'; int f=1; for(int j=2;j<=n;j++) { if(!strstr(str[j],a)) { f=0; break; } } if(f==1) { flag=1; if(strlen(b)<strlen(a)) { strcpy(b,a); } else if(strcmp(b,a)>0) { strcpy(b,a); } } } if(flag==0)break; } if(strlen(b)<3) { cout<<"no significant commonalities\n"; } else cout<<b<<endl; } return 0;}</span>
0 0
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- Poj 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- poj 3080 Blue Jeans
- poj 3080 Blue jeans
- POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans
- POJ 3080-Blue Jeans
- Leetcode - Array - 1. Two Sum (水题,O[n]和O[n^2]实现)
- JVM参数
- 用tensorflow构建线性回归模型
- IOS 多线程技术
- POJ1860——Currency Exchange
- poj 3080 Blue Jeans
- Java中的IO流总结
- npm命令大全
- 【郑轻】[1895]985的0-1串难题
- 第15课:scala类型参数编程实战及spark源码鉴赏
- [Android]Android去掉上方的标题栏。
- 分词词性列表
- 海量大数据解决方案
- quartz集群调度机制调研及源码分析