zoukankan      html  css  js  c++  java
  • Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了。

    我做这题时想的太多了,最简单的暴力枚举起始点却没想到。。。应该先想最简单的方法,层层深入。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<map>
    #include<set>
    #include<vector>
    #include<algorithm>
    #include<stack>
    #include<queue>
    using namespace std;
    #define INF 1000000000
    #define eps 1e-8
    #define pii pair<int,int>
    #define LL long long int
    char s[500];
    int k,ans;
    void check(int b,int e)
    {
        int l=e-b+1;
        if(l&1) return;
        else
        {
            int t=l/2;
            for(int i=b;i<b+t;i++)
            {
                if(s[i]==s[t+i]||s[t+i]==0)
                    continue;
                else return;
            }
            ans=max(ans,l);
            return;
        }
    }
    int main()
    {
        //freopen("in7.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        scanf("%s",s);
        scanf("%d",&k);
        int len=strlen(s);
        int lens=len+k;
        ans=0;
        for(int i=0;i<lens-1;i++)
        {
            for(int j=i+1;j<=lens-1;j++)
            {
                check(i,j);
            }
        }
        printf("%d
    ",ans);
        //fclose(stdin);
        //fclose(stdout);
        return 0;
    }
  • 相关阅读:
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    National Treasures HDU
    Matrix HDU
    过山车 HDU
    Jimmy’s Assignment HDU
    Card Game Cheater HDU
    Uncle Tom's Inherited Land* HDU
    50 years, 50 colors HDU
  • 原文地址:https://www.cnblogs.com/zywscq/p/3950455.html
Copyright © 2011-2022 走看看