• Codeforces Round #253 (Div. 2)A. Anton and Letters


    A. Anton and Letters
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line.

    Unfortunately, from time to time Anton would forget writing some letter and write it again. He asks you to count the total number of distinct letters in his set.

    Input

    The first and the single line contains the set of letters. The length of the line doesn't exceed 1000. It is guaranteed that the line starts from an opening curved bracket and ends with a closing curved bracket. Between them, small English letters are listed, separated by a comma. Each comma is followed by a space.

    Output

    Print a single number — the number of distinct letters in Anton's set.

    Sample test(s)
    input
    {a, b, c}
    
    output
    3
    
    input
    {b, a, b, a}
    
    output
    2
    
    input
    {}
    
    output
    0
    


    就是查字母种类数 大水题

    #include <iostream>
    #include <cstring>
    using namespace std;
    const int inf=0x3f3f3f3f;
    int main()
    {
        int a[30];
        string s;
        getline(cin,s);
        memset(a,0,sizeof(a));
        for(int i=0;i<s.size();i++)
        {
            if(s[i]>='a'&&s[i]<='z')
                a[s[i]-'a']++;
        }
        int ans=0;
        for(int i=0;i<26;i++)
            if(a[i])
            ans++;
        cout<<ans<<endl;
        return 0;
    }
    



  • 相关阅读:
    iOS 自动续期订阅 恢复购买
    iOS内购恢复购买
    iOS内购自动续订
    iOS苹果内购服务端技术方案
    Spring4.x体系架构
    Linux下MySQL主从复制(Binlog)的部署过程
    Linux下MySQL多实例部署记录
    Linux下MySQL基础及操作语法
    Linux下Nginx基础应用
    Linux下Apache(HTTP)基础知识梳理-运维笔记
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6912479.html
Copyright © 2020-2023  润新知