hdu 5842 Lweb and String 字符串水題

比賽的時候硬生生的寫的Longest_increasing_subsequence,結果比賽完才知道原來就是個統計字母個數的。。。英語不好啊啊,GG~~~~

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

char s[110000];
int a[30];
int main()
{
    int t;
    scanf("%d", &t);
    int cnt = 0;
    while(t--){
        memset(a,0,sizeof(a));
        cnt++;
        scanf("%s", s);
        for(int i = 0;s[i];i++){
            a[s[i]-'a']++;
        }
        int sum = 0;
        for(int i = 0;i < 26;i++){
            if(a[i]!=0){
                sum++;
            }
        }
        printf("Case #%d: %d\n", cnt, sum);
    }

    return 0;
}
2016 ccpc 網絡賽

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章