POJ 3080 Blue Jeans(暴力)
来源:互联网 发布:怀孕37周b超标准数据 编辑:程序博客网 时间:2024/06/05 21:06
求出m个串中大于三的最长的公共子串。
范围比较小,暴力就能过。
长度枚举从3开始至60。如果能找出一个公共串就记录,最后记录的一定是最大的。
#include<cstdio>#include<cstring>#include<algorithm>#include<cstdlib>#include<cctype>#include<iostream>#include<cmath>#include<set>using namespace std;char str[11][80],ans[80],x[80];int n;int pd(){ for(int i=1;i<n;i++) { if(strstr(str[i],ans)==NULL) return 0; } return 1;}int main(){ int t; cin>>t; while(t--) { memset(str,0,sizeof(str)); memset(ans,0,sizeof(ans)); memset(x,0,sizeof(x)); cin>>n; for(int i=0;i<n;i++) scanf(" %s",str[i]); int k=3,flag=0; while(k<=60) { memset(ans,0,sizeof(ans)); for(int i=0;i<=60-k;i++) { for(int j=0;j<k;j++) ans[j]=str[0][i+j]; ans[k]='\0'; if(pd()) { flag=1; memcpy(x,ans,sizeof(ans)); } } k++; } if(flag) puts(x); else printf("no significant commonalities\n"); } return 0;}
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(KMP+暴力)
- POJ -3080 Blue Jeans(暴力就可以了)
- POJ 3080 Blue Jeans(暴力枚举+kmp)
- POJ-3080---Blue Jeans (strstr函数暴力求解)
- POJ 3080 Blue Jeans (KMP+暴力枚举)【模板】
- POJ 3080 Blue Jeans(暴力模拟+stl)
- [KMP或者暴力]POJ 3080 Blue Jeans
- POJ 3080 Blue Jeans 暴力枚举+KMP
- POJ 3080 Blue Jeans KMP+暴力
- poj 3080 Blue Jeans (kmp暴力)
- POJ 3080 Blue Jeans (KMP || 暴力)
- poj-3080-Blue Jeans-串-暴力
- Python--ZOJ1350
- 在VC中使用自定义资源制作自解压安装程序
- 大神 PK 红米背后,2G 内存将成互联网手机分水岭
- 腾讯研发工程师A笔试卷
- c语言编程:实现数字的翻转
- POJ 3080 Blue Jeans(暴力)
- 我的自建博客成立啦!wxtlife.com
- 最佳实践:针对性能问题的主动型数据收集 (文档 ID 1549179.1)
- Linux登录验证机制、SSH Bruteforce Login学习
- KNN算法
- 华为模拟题二求一个int型整数的两种递减数之和
- 数据结构-括号匹配程序
- 解决Ubuntu14.04 64bit 安装AndroidSDK后adb命令无法使用问题
- SAP的逻辑数据库