ACdream: ACfun
ACfun
Problem Description
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
In each test case:
Input a string S consist of "A" and "C". The length of S is not large than 100.
Output
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的更多相关文章
- ACdream 之ACfun 题解
A - ACfun Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitSta ...
- ACdream 1214---矩阵连乘
ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...
- acdream.LCM Challenge(数学推导)
LCM Challenge Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- acdream.A Very Easy Triangle Counting Game(数学推导)
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Forma ...
- acdream.Bet(数学推导)
Bet Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Status Pra ...
- acdream.郭式树(数学推导)
郭式树 Time Limit:2000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit Status Pr ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- ACdream 1195 Sudoku Checker (数独)
Sudoku Checker Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
随机推荐
- TopCoder中插件的用法
今天弄了一下TopCoder的插件,发现真的很好很强大,插件的下载地址为 : http://community.topcoder.com/tc?module=Static&d1=applet& ...
- Swift的属性,方法,下标脚本以及继承
从这篇章节起,Swift编程语言指南大部分的重要内容在于概念,代码并非太多.理解Swift的面向对象理念,语法以及类结构,构造析构过程对于非常好的应用Swift语言将会有比較大的帮助. 属性 存储属性 ...
- 图画(txt等一下)实施开放的默认下载的默认浏览器,而不是(Java文本)
在网络上,假设我们超链接地址对应于jpg档,txt档,点击链接,默认浏览器打开这些文件,而不是下载,那么,你如何实现竞争力的默认下载. 1.可通过自己写一个download.jsp来实现 <%@ ...
- ACdream原创群赛(18)のAK's dream题解
只做了4题水题ADGI A题需要注意的就是“[...]”的输出了,何时输出,何时不输出. #include <stdio.h> int main() { int n, cur, d; ; ...
- C++出现计算机术语5
class template(类模板) 可以用来定义一个类定义了一组特定类型的类的.类模板template keyword其次是尖括号(<>)附上.的列表来定义. export keywo ...
- 简说一下coffeescript的constructor是如何导致Backbone.View的事件无法正常工作的.
在继承方面,js还是弱项呀.发现在继承的时候constructor和initialize之分.网上文章没有说明二者关系.看了源码才发现二者的区别呀. 首先我用coffeescript来实现js的继承, ...
- mongodb实现简单的增删改查
package mongoDB; import java.net.UnknownHostException; import java.util.ArrayList; import java.util. ...
- NET MVC运行机制
[图解ASP.NET MVC运行机制理解-简易版] 很多盆友咨询ASP.NET MVC的机制.网上也有好多.但是都是相当深奥.看的云里雾里的.我今天抽空,整理个简易版本.把处理流程走一遍. 当然, ...
- mysql按ID排序(转)
自己建表的时候,把一个字段类型创建为varchar(2) ,其实应该建为int(2)的. 因为我只允许输出数字.这本来也没什么,无非就是占点空间,懒得改了.但是今天在后台发现排序有问题.于是,没办法, ...
- 玩转web之json(五)---将表单通过serialize()方法获取的值转成json
form表单有一个serialize()方法,可以序列化表单的值,但是jquery提供的这个方法会把数据序列化为类似下面的形式: a=1&b=2&c=3&d=4 jquery并 ...