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

题意:推断集合里元素的个数。即不算反复的。

AC代码:

import java.util.*;
public class Main { public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
String s=scan.nextLine();
char a[]=new char[s.length()];
a=s.toCharArray();
int b[]=new int[100];
for(int i=0;i<s.length();i++){
if(a[i]!=' '&&a[i]!=','&&a[i]!='{'){
b[a[i]-'a']=1;
}
if(a[i]=='}') break;
}
int ans=0;
for(int i=0;i<26;i++){
if(b[i]==1)
ans++;
}
System.out.println(ans);
} }



Anton and Letters的更多相关文章

  1. cf443A Anton and Letters

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

  2. A. Anton and Letters

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  3. Y - Anton and Letters

    Problem description Recently, Anton has found a set. The set consists of small English letters. Anto ...

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

    题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...

  5. Codeforces Round 253 (Div. 2)

    layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  6. Codeforces Round #379 (Div. 2) A. Anton and Danik 水题

    A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play ...

  7. C - Anton and Danik

    Problem description Anton likes to play chess, and so does his friend Danik. Once they have played n ...

  8. 【77.39%】【codeforces 734A】Anton and Danik

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. [LeetCode] Remove Duplicate Letters 移除重复字母

    Given a string which contains only lowercase letters, remove duplicate letters so that every letter ...

随机推荐

  1. PCB 一键远程桌面+RDP文件生成

    最近在写个内网INCAM内网授权工具中,在服务端监听客户端请求后,后台自动处理客户端请求并远程客户端 这里记录3个点. 一.运行RDP文件后,正常会有下图2个弹窗,怎么可以关闭这2个弹窗呢, 通过模拟 ...

  2. Kubernetes+Jenkins+Nexus+Gitlab进行CI/CD集成

    前面已经完成了 二进制部署Kubernetes集群,下面进行CI/CD集成. 一.流程说明 应用构建和发布流程说明: 1.用户向Gitlab提交代码,代码中必须包含Dockerfile: 2.将代码提 ...

  3. PowerDesigner常用技巧

    PowerDesigner是非常强大的数据库设计软件,熟练使用PowerDesigner可以使数据库设计高效而简洁.PowerDesign具体操作在帮助文档(按F1)里面有详细描述,这儿只是列出了常用 ...

  4. Linux 安装配置JDK 、 MySQL 、nginx

    今天我来讲一下在Linux下各环境的搭建,主要就讲一下jdk.MySQL.和一个代理服务器nginx 1. jdk的安装配置 1)卸载自带openjdk 当我们拿到一个全新的ECS的时候上面有的会自带 ...

  5. 显示程序输出并复制到文件(tee 命令)

    Linux tee命令用于读取标准输入的数据,并将其内容输出成文件. tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件. 语法 tee [-ai][--help][--v ...

  6. django模型层(二)

    多表操作 创建模型 实例:我们来假定下面这些概念,字段和关系 作者模型:一个作者有姓名和年龄. 作者详细模型:把作者的详情放到详情表,包含生日,手机号,家庭住址等信息.作者详情模型和作者模型之间是一对 ...

  7. X - Vasya and Socks

    Problem description Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pai ...

  8. RabbitMQ 官方NET教程(四)【路由选择】

    在上一个教程中,我们构建了一个简单的日志记录系统. 我们能够广播日志消息给所有你的接收者. 在本教程中,我们将为其添加一个功能 - 我们将让日志接收者可以仅订阅一部分消息. 例如,我们将能够仅将关键的 ...

  9. 三星的Knox Warranty Bit原理

    它是如何触发的? 这个值的状态是烧录在主板上,无法刷写修改, 从0到1 不可逆,除非替换硬件 If a non-Knox boot loader or kernel has been installe ...

  10. 使用T-sql建库建表建约束

    为什么要使用sql语句建库建表? 现在假设这样一个场景,公司的项目经过测试没问题后需要在客户的实际环境中进行演示,那就需要对数据进行移植,现在问题来了:客户的数据库版本和公司开发阶段使用的数据库不兼容 ...