zoukankan      html  css  js  c++  java
  • POJ 3080 Blue Jeans

    //本题爆搜即可......
    //含有一点是要按字典序排序,输出最小值
    //程序写得太麻烦了.....

    code
    #include<iostream>
    using namespace std;

    int sub(char* a,char* b,int n)
    {
        
    int i,j;
        
    for( i=0;i<=60-n;++i)
        {
            
    for( j=0;j<n;++j)
                
    if(a[j]!=b[j+i])
                    
    break;
            
    if(j==n)
                
    return 1;
        }

        
    return 0;
    }
    //是否字串
    int main()
    {
        
    char a[61],b[15][61],temp[61],tag[100];
        
    int i,j,total,n,index,k,t,num,tag1,tag2,tag3;
        cin
    >>total;
        
    while(total--)
        {
            cin
    >>n;
            cin
    >>a;
            
    for(i=0;i<n-1;++i)
                cin
    >>b[i];
            
    for(i=60;i>2;--i)
            {
                index
    =0;
                num
    =0;
                tag3
    =0;
                
    for(j=0;j<=60-i;++j)
                {
                    tag1
    =0;
                    tag2
    =0;
                    
    for(k=0;k<n-1;++k)
                    {
                        
    if(sub(&a[j],b[k],i))
                            ;
                        
    else break;
                    }
                    
    if(k==n-1)
                    {
                        tag3
    =1;//有公共
                        if(tag1==1)
                        {
                            tag2
    =0;
                            
    for(t=0;t<i;++t)
                                
    if(a[j+t]<temp[t])
                                {
                                    tag2
    =1;
                                    
    break;
                                }
                                
    else if(a[j+t]>temp[t])
                                    
    break;
                            
    if(tag2==1)
                                
    for(t=0;t<i;++t)
                                    temp[t]
    =a[j+t];
                        }
                        
    else
                        {
                            tag1
    =1;
                            
    for(t=0;t<i;++t)
                                temp[t]
    =a[j+t];
                        }
                    }

                }
                
                
    if(tag3)
                {
                    num
    =i;
                    i
    =-1;
                    
    break;
                }
            }
            
    if(num==0)
                cout
    <<"no significant commonalities";
            
    for(t=0;t<num;++t)
                cout
    <<temp[t];
            cout
    <<endl;

            
        }
                    

    }

  • 相关阅读:
    Java设计模式之单例模式
    sql查询优化整理
    MYSQL 调优学习笔记
    记一次失败的大厂面试
    ElasticSearch 6.3.2 整合 Springboot 2.1.10.RELEASE 版本,使用 Logstash 导入 mysql 数据
    ajax技术实现登录判断用户名是否重复以及利用xml实现二级下拉框联动
    浅谈 KMP 算法
    转载:Docker入门只需看这一篇就够了
    Spring Boot 监听 Activemq 中的特定 topic ,并将数据通过 RabbitMq 发布出去
    hadoop入门之海量Web日志分析 用Hadoop提取KPI统计指标
  • 原文地址:https://www.cnblogs.com/lvpengms/p/1662756.html
Copyright © 2011-2022 走看看