HDU 5842 Lweb and String

所有不同的字母都作为一次贡献是最大的。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-8;
void File()
{
    freopen("D:\in.txt","r",stdin);
    freopen("D:\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
    while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
}

const int maxn=100010;
char s[maxn];
int T,ans,f[maxn];

int main()
{
    int cas=1;
    scanf("%d",&T); while(T--)
    {
        memset(f,0,sizeof f); ans=0; scanf("%s",s);
        for(int i=0;s[i];i++) if(f[s[i]]==0) ans++,f[s[i]]=1;
        printf("Case #%d: %d
",cas++,ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/5782086.html