标签:des style http java color 数据
1 ACAC
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;
}
标签:des style http java color 数据
原文地址:http://blog.csdn.net/u013487051/article/details/37720411