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. 使用MYCAT作为Mysql HA的中间件(转)

    记得在上一篇文章“Java集群--大型网站是怎样解决多用户高并发访问的”的结尾处本人阐述了数据库的高可用的一种方案----实现主从部署,那么今天,就让我聊聊本人关于数据库的一些所思所想吧! 下面是本人 ...

  2. LDA主题模型学习笔记3.5:变分參数推导

    如今来推导一下得到变分參数更新式的过程.这一部分是在论文的附录中,为避免陷入过多细节而影响总体理解.能够在刚開始学习LDA的时候先不关注求解细节.首先要把L写成关于γ,ϕ\gamma,\phi函数.依 ...

  3. GCC的使用(编译,链接,运行)

    以下这三篇日志非常的好,真的非常的好.介绍使用gcc编译,链接,运行c程序. 1.http://lveyo.iteye.com/blog/240578 2.http://lveyo.iteye.com ...

  4. MySQL创建用户权限结果Trigger失败

    说来惭愧,MySQL我已经在只将用于,非常赞赏阶段. 甚至一些比较深层次的管理,不熟悉如何,我们要加强啊! 最近.系统测试,使用MySQL数据库,你需要在表上创建触发器.该数据库是安装在机.但.在任何 ...

  5. 使用ReactiveCocoa实现iOS平台响应式编程

    使用ReactiveCocoa实现iOS平台响应式编程 ReactiveCocoa和响应式编程 在说ReactiveCocoa之前,先要介绍一下FRP(Functional Reactive Prog ...

  6. mmc生产任务分配问题

    mmc生产任务分配问题,本题目简单.

  7. Windows Phone开发(35):使用Express Blend绘图

    原文:Windows Phone开发(35):使用Express Blend绘图 上一节中我们简单扯了一下绘图指令,然而那也不是最简单的绘图法,今天,我再向大家推荐一种更好的绘图方案--Express ...

  8. An Overview of Complex Event Processing

    An Overview of Complex Event Processing 复杂事件处理技术概览(一) 翻译前言:我在理解复杂事件处理(CEP)方面一直有这样的困惑--为什么这种计算模式是有效的, ...

  9. 阅读:AirBag Boosting Smartphone Resistance to Malware Infection

  10. Asp.net MVC4之 一个简单的小例子

    练习: 新建一个mvc项目 要求: 有3个视图  Login Index Details 目的:感受一下MVC与传统WebForm的差异性 WebForm的请求模型 MVC请求模型 传统WebForm ...