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);
}
}
按字母出现的顺序编号,问最长上升子序列。
思路:
最长为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);
}
}
相关文章推荐
- HDU5842——Lweb and String(CCPC网络赛第11题)
- CCPC网络赛,HDU_5842 Lweb and String
- HDU-5842-Lweb and String【2016CCPC网络赛】
- HDU 4758 Walk Through Squares (2013南京网络赛1011题,AC自动机+DP)
- HDU 5052 Yaoge’s maximum profit(树链剖分+线段树,2014上海网络赛1011)
- A Secret 2017 CCPC 网络选拔赛 hdu 6153
- HDU - 6216 A Cubic number and A Cubic Number (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1011)
- HDU 6153 A Secret CCPC网络赛,KMP拓展应用
- HDU 4277 USACO ORZ 第37届ACM/ICPC长春赛区网络赛1011题(搜索)
- hdu 5889 Barricade 2016ACM/ICPC青岛赛区网络赛1011
- HDU-5833-Zhu and 772002【2016CCPC网络赛】【高斯消元】
- hdu 5017 Ellipsoid(西安网络赛 1011)
- HDU 5832——A water problem & 2016CCPC网络赛1001
- hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)
- HDU-5832-A water problem【2016CCPC网络赛】
- hdu 5017 Ellipsoid(西安网络赛 1011)
- hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法
- hdu 5840 This world need more Zhu (2016CCPC 网络赛1009) 分块+线段树
- 简单规律 HDU - 6154 CaoHaha's staff[2017 CCPC网络选拔赛]
- ccpc 网络赛 hdu 6155