Anton and Letters
Anton and Letters
2 seconds
256 megabytes
standard input
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.
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.
Print a single number — the number of distinct letters in Anton's set.
{a, b, c}
3
{b, a, b, a}
2
{}
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的更多相关文章
- cf443A Anton and Letters
A. Anton and Letters time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- A. Anton and Letters
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Y - Anton and Letters
Problem description Recently, Anton has found a set. The set consists of small English letters. Anto ...
- Codeforces Round #253 (Div. 2) A. Anton and Letters
题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...
- Codeforces Round 253 (Div. 2)
layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- 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 ...
- C - Anton and Danik
Problem description Anton likes to play chess, and so does his friend Danik. Once they have played n ...
- 【77.39%】【codeforces 734A】Anton and Danik
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- [LeetCode] Remove Duplicate Letters 移除重复字母
Given a string which contains only lowercase letters, remove duplicate letters so that every letter ...
随机推荐
- Java执行定时任务
一.用java.util.Timer 使用JAVA类Timer可实现简单的延迟和周期性任务,其中的任务使用java.util.TimerTask表示.任务的执行方式有两种: 按固定速率执行:即sche ...
- 网上订餐系统的SQL SERVER 2005数据库连接
- selenium3 + Python - 处理浏览器弹窗(转载)
作者:Real_Tino 转载链接:https://blog.csdn.net/real_tino/article/details/59068827 我们在浏览网页时经常会碰到各种花样的弹窗,在做UI ...
- selenium3 + python - gird分布式(转载)
本篇转自博客:上海-小T 转载链接:https://blog.csdn.net/real_tino/article/details/53467406 Selenium grid是用来分布式执行测试用例 ...
- Python 30 单例模式
单例模式 多次实例化的结果指向同一个实例 单例模式实现方式 import settings #方式一: class MySQL: __instance=None def __init__(self,i ...
- golang闭包,传统斐波那契
package main import ( "fmt") func main() { f := fibonacci() for i := 0; i < 10 ...
- MySQL 数据的增删改查
一.数据库的增删改 一. 在MySQL管理软件中,可以通过SQL语句中的DML语言来实现数据的操作,包括 1.使用INSERT实现数据的插入 2.UPDATE实现数据的更新 3.使用DELETE实现数 ...
- xhtml1-frameset.dtd
<!-- Extensible HTML version 1.0 Frameset DTD This is the same as HTML 4 Frameset except for chan ...
- ASP.NET MVC + 工厂模式 + 三层 + 缓存
最近将手头的项目总结整理了一下,以方便自己的学习.... 下面直接上图先介绍项目的结构图: 项目是ASP.NET MVC 4.0的应用程序,DBUtility这个类库主要是DbHelper操作数据库的 ...
- CentOS7.5 AndroidStudio Debug报错:insufficient permissions for device
/ ::: Launching instantapp $ adb push /home/vevi/AndroidStudioProjects/WeChatGod/app/build/outputs/a ...