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. XHTML学习笔记

    1.每个网页都是在XML声明和DTD之后以一个<html>标记开始,以一个</html>标记结束 这两个标记表明在它们之间的所有文本都是HTML格式,他告诉浏览器如何理解该文档 ...

  2. AngularJS是为了克服HTML在构建应用上的不足而设计的

    AngularJS中文网:http://www.apjs.net/ 简介   AngularJS是为了克服HTML在构建应用上的不足而设计的.HTML是一门很好的为静态文本展示设计的声明式语言,但要构 ...

  3. QT怎样在QTableWidge显示图片

      <span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">QTableWi ...

  4. Vsphere client 无法登陆VCenter 处理的方法

    上周做安全的时候将DC.DB和VCenter 三台机器的防火墙都启用了,结果Vcenter 登陆的时候总是提示服务器没有响应,连web client 都无法登陆. 处理过程 一.首先要保证 vmvar ...

  5. POJ 1838 Banana (并查集)

    Description Consider a tropical forrest, represented as a matrix. The cell from the right top corner ...

  6. 《UNIX编程环境》的源代码的第二个版本Ubuntu下编

    1.在http://www.apuebook.com下载源代码 2. 视图READ root@ubuntu:/home/wl/mywork/apue.2e# cat -n README 1 Read ...

  7. openwrt教程 第一章 物联网&amp;openwrt开发概述

    1.1 我们的宗旨 互联网.移动互联网的时代已经过去,物联网的时代已经来临!2014年,是物联网元年,2016年,物联网将达到高潮!为了迎接该潮流,我们工作室(F403科技创意室:http://f40 ...

  8. FluentData

    FluentData微型ORM 最近在帮朋友做一个简单管理系统,因为笔者够懒,但是使用过的NHibernate用来做这中项目又太不实际了,索性百度了微型ORM,FluentData是第一个跳入我眼睛的 ...

  9. pygame系列_font游戏字体

    在pygame游戏开发中,一个友好的UI中,漂亮的字体是少不了的 今天就给大伙带来有关pygame中字体的一些介绍说明 首先我们得判断一下我们的pygame中有没有font这个模块 1 if not ...

  10. 矩形旋转碰撞,OBB方向包围盒算法实现

    怎样进行2D旋转矩形的碰撞检測.能够使用一种叫OBB的检測算法(Oriented bounding box)方向包围盒.这个算法是基于SAT(Separating Axis Theorem)分离轴定律 ...