zoukankan      html  css  js  c++  java
  • ACdream 1125(ACfun-字典序)

    A - ACfun

    Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

    Problem Description

    As a former ACMer, "AC" is a special abbreviated word which can bring much pleasure to me. Sometimes it means everything.
    This problem is about "AC".
    One day, I write a long string S on the paper which contains "A" and "C". Now I want to find a lexicographic minimum string T satisfied that T is distinct with all substring of S.

    Input

    The first line of input file contains an integer T indicating the number of case.
    In each test case:
    Input a string S consist of "A" and "C". The length of S is not large than 100.

    Output

    For each test case:
    You should output the string T meet the condition.

    Sample Input

    1
    ACAC

    Sample Output

    AA
    

    字典序:AAAAA<AC

    本题:找字典序最小字符串T。其不在S中出现,仅仅包括'A''C'


    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<functional>
    #include<iostream>
    #include<cmath>
    #include<cctype>
    #include<ctime>
    using namespace std;
    #define For(i,n) for(int i=1;i<=n;i++)
    #define Fork(i,k,n) for(int i=k;i<=n;i++)
    #define Rep(i,n) for(int i=0;i<n;i++)
    #define ForD(i,n) for(int i=n;i;i--)
    #define RepD(i,n) for(int i=n;i>=0;i--)
    #define Forp(x) for(int p=pre[x];p;p=next[p])
    #define Lson (x<<1)
    #define Rson ((x<<1)+1)
    #define MEM(a) memset(a,0,sizeof(a));
    #define MEMI(a) memset(a,127,sizeof(a));
    #define MEMi(a) memset(a,128,sizeof(a));
    #define INF (2139062143)
    #define F (100000007)
    #define MAXN (100000+100)
    long long mul(long long a,long long b){return (a*b)%F;}
    long long add(long long a,long long b){return (a+b)%F;}
    long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
    typedef long long ll;
    char s[MAXN];
    int main()
    {
    //	freopen("A.in","r",stdin);
    //	freopen(".out","w",stdout);
    	
    	int t;
    	scanf("%d
    ",&t);
    	while (t--)	
    	{
    		scanf("%s",s);
    		int n=strlen(s),p=0,t=0;
    		Rep(i,n)
    		{
    			if (s[i]=='A') p++;else p=0;
    			t=max(t,p);
    		}++t;
    		while(t--) printf("A");printf("
    ");
    	//	else printf("%s
    ",s);
    	}
    	
    	return 0;
    }
    





  • 相关阅读:
    逆向学习-内嵌补丁(洞穴代码)
    ubuntu下创建ftp用户,该用户只访问特定目录下的内容
    Ubuntu 14.04 FTP服务器--vsftpd的安装和配置
    Hdu 4223 Dynamic Programming?
    Hdu 3873 Invade the Mars
    Hdu 2025 查找最大元素
    Hdu 1520 Anniversary party
    Hdu 4283 You Are the One
    HTTP协议
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/lytwajue/p/7122900.html
Copyright © 2011-2022 走看看