zoukankan      html  css  js  c++  java
  • 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;
    }
    



  • 相关阅读:
    manjaro开机出现grub 解决办法
    goquery 解析不了noscript
    同步服务器时间
    phpStorm中使用xdebug工具调试docker容器中的程序
    Goutte 获取http response
    在微信浏览器里使用js或jquery实现页面重新刷新
    Node Sass does not yet support your current environment
    微信支付服务商模式
    PHP获取月末时间
    JavaScript DOM 对象
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6912479.html
Copyright © 2011-2022 走看看