poj 3080
来源:互联网 发布:python 日期格式 编辑:程序博客网 时间:2024/06/14 03:47
虽然说很简单,但我犯了很多错
第一个错是应该从1开始枚举,不小心写成了2;
第二错是strstr是看后面是前面的子集;
第三个错是没有清空s;
代码如下
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;char a[15][65];char s[65],temp[65];int main() {int t;scanf("%d",&t);while(t--){memset(s,0,sizeof(s));int m;scanf("%d",&m);for(int i=0;i<m;i++)scanf("%s",a[i]); int l=60,t=0;while(l){for(int i=0;i<=60-l;i++){int len=0;for(int j=i;;j++){temp[len++]=a[0][j];if(len==l) break;}temp[l]='\0';bool flag=true;for(int j=1;j<m;j++){if(!strstr(a[j],temp)){flag=false;break;}} if(flag){if(t==1){if(strcmp(s,temp)>0){strcpy(s,temp);}}if(t==0){strcpy(s,temp);t=1;}}}if(strlen(s)>0) break;l--;}if(strlen(s)>=3) printf("%s\n",s);else printf("no significant commonalities\n");}}
阅读全文
0 0
- POJ 3080
- poj 3080
- poj.3080
- poj 3080
- poj-3080
- poj 3080
- poj 3080
- poj 3080
- poj-3080
- poj-3080
- POJ 3080
- poj 3080
- POJ 3080 POJ 3450 KMP
- poj 3080 kmp
- poj 3080 Blue Jeans
- poj 3080 KMP+暴力
- poj 3080 Blue Jeans
- poj 3080 Blue Jeans
- 【BootStrap】图片样式、辅助类样式和CSS组件 -附源码
- C#进阶 04 变量
- Java与Cuda混合编程
- Codeforces 535C Tavas and Karafs(二分)
- 献给初学者:谈谈如何学习Linux操作系统
- poj 3080
- 图床
- hostname与/etc/hostst ; /etc/sysconfig/network的关系
- POJ3273
- 解题报告:Codeforces Round #432 (Div. 1) D. Tournament Construction (DP+构造)
- 学生管理系统总结(一)
- C-一个通用查找函数
- 数据挖掘领域重要会议与期刊情况
- 新博客地址