码迷,mamicode.com
首页 > 其他好文 > 详细

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A

时间:2017-09-08 18:11:37      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:c++   combine   ace   title   load   nat   any   ast   out   

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

题意:没啥好说的

解法:根据出现的字母,看能不能组合出来就行

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 string s;
 4 map<char,int>Mp;
 5 int MAX=(1<<31)-1;
 6 //Bulbasaur
 7 int main()
 8 {
 9     cin>>s;
10     int len=s.length();
11     for(int i=0;i<len;i++){
12         Mp[s[i]]++;
13     }
14     MAX=min({MAX,Mp[B],Mp[u]/2,Mp[l],Mp[b],Mp[a]/2,Mp[s],Mp[r]});
15     cout<<MAX<<endl;
16     return 0;
17 }

 

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A

标签:c++   combine   ace   title   load   nat   any   ast   out   

原文地址:http://www.cnblogs.com/yinghualuowu/p/7495025.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!