Anton and Letters

简介: Anton and Letters

文章目录

一、Anton and Letters

总结


一、Anton and Letters

本题链接:Anton and Letters


题目:

A. Anton and Letters

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard 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.


Examples

input

{a, b, c}

output

3

input

{b, a, b, a}

output

2

input

{}

output

0

本博客给出本题截图

image.png

题意:输入一个集合,去重后问集合内的元素个数

AC代码

#include <cstdio>
#include <set>
#include <iostream>
using namespace std;
set<int> s;
int main()
{
    char c;
    scanf("%c", &c);
    char a;
    while (cin >> a)
    {
        if (a == '}') break;
        if (a == ',' || a == ' ') continue;
        s.insert(a);
    }
    printf("%d\n", s.size());
    return 0;
}

总结

水题,不解释


目录
相关文章
|
12月前
1212:LETTERS
1212:LETTERS
|
8月前
|
Java
Leetcode 3. Longest Substring Without Repeating Characters
此题题意是找出一个不包含相同字母的最长子串,题目给出了两个例子来说明题意,但这两个例子具有误导性,让你误以为字符串中只有小写字母。还好我是心机boy,我把大写字母的情况也给考虑进去了,不过。。。。字符串里竟然有特殊字符,于是贡献了一次wrong answer,这次我把ascii字符表都考虑进去,然后就没问题了。这个故事告诫我们在编程处理问题的时候一定要注意输入数据的范围,面试中可以和面试官去确认数据范围,也能显得你比较严谨。
34 3