POJ3080-Blue Jeans
来源:互联网 发布:三端口环行器 编辑:程序博客网 时间:2024/06/05 22:56
暴力点,解题的方式暴力点。
通过枚举第一个字符串中的所有长度大于3的子串然后逐一去看是否匹配即可。
#include <cstdio>#include <cstring>char str[15][70];char pat[70];char ans[70];int main(int argc, char const *argv[]) { int t; scanf("%d", &t); while (t--) { int m; scanf("%d", &m); for (int i = 0; i < m; i++) { scanf("%s", str[i]); } int cnt = 0; int len = strlen(str[0]); for (int i = 0; i < len; i++) { for (int j = 3; i + j - 1 < len; j++) { bool ok = true; for (int k = 1; k < m; k++) { memset(pat, '\0', sizeof(pat)); strncpy(pat, str[0] + i, j); if (strstr(str[k], pat) == NULL) { ok = false; break; } } if (ok) { if (j > cnt || (j == cnt && strcmp(pat, ans) < 0)) { memset(ans, '\0', sizeof(ans)); strcpy(ans, pat); cnt = j; } } else { break; } } } if (cnt < 3) { puts("no significant commonalities"); } else { puts(ans); } } return 0;}
0 0
- poj3080 blue Jeans
- poj3080 Blue Jeans-------KMP
- Blue Jeans poj3080
- POJ3080 Blue Jeans
- POJ3080:Blue Jeans
- POJ3080 Blue Jeans
- poj3080 Blue Jeans
- [POJ3080] Blue Jeans
- POJ3080 Blue Jeans
- POJ3080 Blue Jeans
- poj3080 Blue Jeans
- POJ3080-Blue Jeans
- POJ3080 Blue Jeans
- POJ3080-Blue Jeans
- poj3080 Blue Jeans
- POJ3080《Blue Jeans》方法:暴力
- POJ3080:Blue Jeans(后缀数组)
- POJ3080 Blue Jeans(kmp & 暴力)
- 小谈js原型链和继承
- CPU 型号后所代表的字母的意思
- 欢迎使用CSDN-markdown编辑器
- C语言的符号表和类型系统2
- C#接口查询(QI)
- POJ3080-Blue Jeans
- BZOJ1649: [Usaco2006 Dec]Cow Roller Coaster 背包DP
- 剑指Offer——美团内推+校招笔试题+知识点总结
- 最长公共子序列
- Spring缓存注解@Cache使用
- java中的堆和栈
- 【WWDC2016 Session】iOS 10 推送Notification新特性
- USB 2.0 A型、B型、Mini和Micro接口 type-c 定义及封装
- MySQL创建Function时报错误码1418的解决方案