CodeForces757A
A. Gotta Catch Em' All!
256 megabytes
standard input
standard output
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out and catch Bulbasaur, he came up with his own way of catching a Bulbasaur.
Each day, he takes the front page of the newspaper. He cuts out the letters one at a time, from anywhere on the front page of the newspaper to form the word "Bulbasaur" (without quotes) and sticks it on his wall. Bash is very particular about case — the first letter of "Bulbasaur" must be upper case and the rest must be lower case. By doing this he thinks he has caught one Bulbasaur. He then repeats this step on the left over part of the newspaper. He keeps doing this until it is not possible to form the word "Bulbasaur" from the newspaper.
Given the text on the front page of the newspaper, can you tell how many Bulbasaurs he will catch today?
Note: uppercase and lowercase letters are considered different.
Input
Input contains a single line containing a string s (1 ≤ |s| ≤ 105) — the text on the front page of the newspaper without spaces and punctuation marks. |s| is the length of the string s.
The string s contains lowercase and uppercase English letters, i.e. .
Output
Output a single integer, the answer to the problem.
Examples
input
Bulbbasaur
output
1
input
F
output
0
input
aBddulbasaurrgndgbualdBdsagaurrgndbb
output
2
Note
In the first case, you could pick: Bulbbasaur.
In the second case, there is no way to pick even a single Bulbasaur.
In the third case, you can rearrange the string to BulbasaurBulbasauraddrgndgddgargndbb to get two words "Bulbasaur".
//2017.01.18
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int inf = 0x3f3f3f3f;
int book[]; int main()
{
string str;
string bul = "Bulbbasaur";
while(cin >> str)
{
memset(book, , sizeof(book));
for(int i = ; i < str.length(); i++)
book[str[i]]++;
book['u']/=;
book['a']/=;
int ans = inf;
for(int i = ; i < bul.length(); i++)
if(ans > book[bul[i]])
ans = book[bul[i]];
cout<<ans<<endl;
} return ;
}
CodeForces757A的更多相关文章
随机推荐
- TCP重传问题解决思路
处理线上问题经常会碰到网络抖动的情况, 网络抖动有可能就是TCP重传导致,下面简单说下TCP重传的排查思路,不一定能完全解决问题 1. 找运维同事确定是否是网线问题, 如果是网线问题请更换网线 2. ...
- 如何获取app的素材,做出一个高仿的app
第一步:在iTunes中搜索你想要的app,然后点击下载: 下载完成之后右键点击:在Finder中显示 在finder中右键用"归档工具打开" 会显示如下内容: "显示包 ...
- Codeforces#364Div2
A题: 题意:给定一些数,然后每两个组成一对,要求每对的和的大小相同,输出这样的组合 分析:直接模拟就行 #include <iostream> #include <cstdio&g ...
- 《数据结构与算法分析:C语言描述》读书笔记------练习1.1 求第K大的数
求一组N个数中的第k个最大者,设k=N/2. import java.util.Random; public class K_Max { /** * @param args */ //求第K大的数,保 ...
- Tessnet2图片识别(2)
1. 引用 tessnet2.dll (只有NET2.0版本) 2. 视图页 <%@ Page Language="C#" MasterPageFile="~/Vi ...
- 安装了C
2014-04-09 13:19:30 大学里看的第一本编程书籍,就是C.但是一直没有编译. 今天首次安装,我也佩服当初我是怎么通过C二级的. 上午写了sds手册.其中的制图用的visio制图,非常好 ...
- jdk8 之 java.time包AND DateUtils
package com.jansh.comm.util; import java.time.Clock; import java.time.LocalDate; import java.time.Lo ...
- iOS UITabBar
参考文章:http://www.cnblogs.com/wendingding/p/3775488.html 简单明了,不用再总结了.
- Python3基础 set() 集合 创建集合与特点:自动将重复合并掉 不支持索引
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- 全局文件 pch
在 bulding setting 里面 搜 prefix header 然后添加自己的pch 路径, 类似 $(SRCROOT)/... 还要把 precompile prefix header 设 ...