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

题意是要输出最小的字典序。且不是原字符串的的子串。。找到最长连续A子串。

由于要不属于原字符串所以再在其后加一A就可以。

在给些数据吧。

5

A

C

AACAAA

ACACA

CCCAA

AA

A

AAAA

AA

AAA

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue> using namespace std; int main()
{
char str[108];
int ans;
int t;
scanf("%d", &t);
while( t-- )
{
scanf("%s", str);
int num=0;
ans=0;
for(int i=0; i<strlen(str); i++)
{
if(str[i]=='A')
num++;
for(int j=i+1; j<strlen(str); j++)
{
if(str[j]=='A')
num++;
if(str[j]!='A')
break;
}
if(ans<num)
ans=num;
num=0;
}
for(int i=1; i<=ans+1; i++)
cout<<"A";
cout<<endl;
} return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

ACdream: ACfun的更多相关文章

  1. ACdream 之ACfun 题解

    A - ACfun Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitSta ...

  2. ACdream 1214---矩阵连乘

    ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...

  3. acdream.LCM Challenge(数学推导)

     LCM Challenge Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit ...

  4. acdream.Triangles(数学推导)

    Triangles Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Stat ...

  5. acdream.A Very Easy Triangle Counting Game(数学推导)

    A - A Very Easy Triangle Counting Game Time Limit:1000MS     Memory Limit:64000KB     64bit IO Forma ...

  6. acdream.Bet(数学推导)

    Bet Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Status Pra ...

  7. acdream.郭式树(数学推导)

    郭式树 Time Limit:2000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit Status Pr ...

  8. ACdream 1188 Read Phone Number (字符串大模拟)

    Read Phone Number Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Sub ...

  9. ACdream 1195 Sudoku Checker (数独)

    Sudoku Checker Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit ...

随机推荐

  1. poj2777--Count Color(线段树,二进制转化)

    Count Color Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 34950   Accepted: 10542 Des ...

  2. 64位CentOS5.6安装Mysql 5.5.11GA

    1.更新并查看当前CentOS版本是否为5.6yum updatelsb_release -a 2.下载文件下载 bison-2.4.3.tar.gz到/usr/local/src下载 cmake-2 ...

  3. ASP.NET关于Login控件使用,LoginView 控件,CreateUserWizard 控件

    原文:ASP.NET关于Login控件使用,LoginView 控件,CreateUserWizard 控件 Login控件它是属于Membership服务的一部分,必须配置Membership提供程 ...

  4. hdu 4857 逃生 拓扑排序+PQ,剥层分析

    pid=4857">hdu4857 逃生 题目是求拓扑排序,但不是依照字典序最小输出,而是要使较小的数排在最前面. 一開始的错误思路:给每一个点确定一个优先级(该点所能到达的最小的点) ...

  5. 黄聪:Microsoft Enterprise Library 5.0 系列教程(一) Caching Application Block (高级)

    原文:黄聪:Microsoft Enterprise Library 5.0 系列教程(一) Caching Application Block (高级) Caching Application Bl ...

  6. HTML中心在页面上弹出自定义表单层(实现可能拖累)

    使用DIV窗体来动态显示内容的原理:首先採用CSS和HTML隐藏弹窗中的内容,然后利用JavaScript(本教程中是JQuery)来动态显示它们.这样的效果不仅可以充分利用有限的版面空间,并且可以提 ...

  7. MySQL先进的技术-存储引擎

    MySQL功能被分成两部分,主要有成品的外部client连接和可行性研究SQL函数语句,内侧部分被称为存储引擎,它负责接收外部操作指令数据,实际数据是完整的,文件输入和输出操作的工作 版权声明:本文博 ...

  8. IP Camera 和 Web Camera 差分

    一直以来,,没太注意IP camera 和 Web Camera之间的差,这两个摄像头,昨天晚上.闲来无事Google少数,我们发现,还有两者之间的差异. 1) IP Camera IP Camera ...

  9. poj 1959 Darts 同意反复组合

    水题.直接贴代码. //poj 1959 //sep9 #include <iostream> using namespace std; int n; int f[128]; int so ...

  10. ios在SQLite3基本操作

    iOS关于sqlite3操作 iPhone中支持通过sqlite3来訪问iPhone本地的数据库. 详细用法例如以下 1:加入开发包libsqlite3.0.dylib 首先是设置项目文件.在项目中加 ...