您的位置:首页 > 理论基础 > 计算机网络

HDU 5842—— Lweb and String & CCPC 网络赛 1011

2016-08-15 20:38 375 查看
题意:

按字母出现的顺序编号,问最长上升子序列。

思路:

最长为26,出现一个新的字母就加上,答案为字母的种数,无聊的题目。

code:

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;

const int N=1e5+5;
string s;
int st[28];
int main()
{
int T;
scanf("%d",&T);
for (int ca=1;ca<=T;ca++){
memset(st,0,sizeof(st));
cin>>s;int ans=0;
for (int i=0;i<s.size();i++){
st[s[i]-'a']++;
if (st[s[i]-'a']==1) ans++;
}
printf("Case #%d: %d\n",ca,ans);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: