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的更多相关文章
随机推荐
- Modbus测试工具 :Modbus Poll,Modbus Slave
源:http://blog.sina.com.cn/s/blog_49352090010138e7.html Modbus测试工具 :Modbus Poll,Modbus Slave
- Ubuntu 12.04下安装thrift 0.9
Thrift这里就不介绍了,只说一句--Facebook很牛逼. 我这里安装Thrift主要是为Accumulo数据库作准备,所以java语言为必选项. 具体安装参考官方Apache Thrift R ...
- (五)Jquery Mobile列表
Jquery Mobile列表 一.JM列表 1.普通列表 效果: 带序号的列表 将ul换成ol 效果: 2.data-inset=& ...
- Python正则表达式,统计分析nginx访问日志
目标: 1.正则表达式 2.oop编程,统计nginx访问日志中不同IP地址出现的次数并排序 1.正则表达式 #!/usr/bin/env python # -*- coding: utf-8 -*- ...
- ReactiveNative学习之Diff算法
React 源码剖析系列 - 不可思议的 react diff深入浅出React(四):虚拟DOM Diff算法解析React diff 算法总结链接引用的文章React出于性能的考虑,为了避免频繁操 ...
- Identifying Dialogue Act Type
Natural Language Processing with Python Chapter 6.2 import nltk from nltk.corpus import nps_chat as ...
- iOS 添加手机密码、指纹进行安全验证
为APP添加安全验证 1.导入头文件 #import <LocalAuthentication/LocalAuthentication.h> 2.添加手机密码验证 //创建安全验证对象 L ...
- AnsiString用法(转)
源:AnsiString用法 //Ansistring 转 char void __fastcall TForm1::Button1Click(TObject *Sender) { AnsiStrin ...
- C++通过Callback向C#传递数据,注意问题
转载:出处 现在比较流行C#与C++融合:C#做GUI,开发效率高,C++做运算,运行效率高,二者兼得. 但是C++与C#必然存在数据交互,C#与C++dll的数据交互从来都是一个让人头疼的问题. 从 ...
- (C#)利用Aspose.Cells组件导入导出excel文件
Aspose.Cells组件可以不依赖excel来导入导出excel文件: 导入: public static System.Data.DataTable ReadExcel(String strFi ...