标签:des style class blog code http
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 11542 | Accepted: 4962 |
Description
Input
Output
Sample Input
3 2 GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 3 GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA GATACTAGATACTAGATACTAGATACTAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA GATACCAGATACCAGATACCAGATACCAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA 3 CATCATCATCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC ACATCATCATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AACATCATCATTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
Sample Output
no significant commonalities AGATAC CATCATCAT
Source
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char str[12][100],ch[100],ans[100]; int main() { int t,i,j,k,n,maxl,f; cin>>t; while(t--) { memset(str,0,sizeof(str)); memset(ans,0,sizeof(ans)); cin>>n; maxl=0,f=0; for(i=0; i<n; i++) cin>>str[i]; for(i=0; i<58; i++) { for(j=3; j<=60-i; j++) { strncpy(ch,str[0]+i,j); ch[j]=0; f=0; for(k=1; k<n; k++) { if(strstr(str[k],ch)==NULL) { f=1; break; } } if(!f) { if(j>maxl) { maxl=j; strcpy(ans,ch); } else if(j==maxl) { if(strcmp(ch,ans)<0) strcpy(ans,ch); } } } } if(maxl) cout<<ans<<endl; else cout<<"no significant commonalities"<<endl; } return 0; }
POJ训练计划3080_Blue Jeans(串处理/暴力),布布扣,bubuko.com
POJ训练计划3080_Blue Jeans(串处理/暴力)
标签:des style class blog code http
原文地址:http://blog.csdn.net/juncoder/article/details/30505407