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 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 a single integer, the answer to the problem.
Bulbbasaur
1
F
0
aBddulbasaurrgndgbualdBdsagaurrgndbb
2
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".
题意:有很多卡片,一张卡片一个字母,问能组成多少个Bulbasaur
水题
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main()
{
// freopen("shuju.txt","r",stdin);
char a[100000+10];
cin>>a;
int len=strlen(a);
int s[10];
for(int i=0;i<len;i++)
{
if(a[i]=='B')
s[0]++;
else if(a[i]=='u')
s[1]++;
else if(a[i]=='l')
s[2]++;
else if(a[i]=='b')
s[3]++;
else if(a[i]=='a')
s[4]++;
else if(a[i]=='s')
s[5]++;
else if(a[i]=='r')
s[6]++;
}
s[1]/=2;
s[4]/=2;
sort(s,s+7);
printf("%d\n",s[0]);
// for(int i=0;i<7;i++)
// printf("%d ",s[i]);
// printf("\n");
// printf("## %s\n",a);
return 0;
}
本文介绍了一个简单的编程问题,任务是计算给定字符串中可以组成的'Bulbasaur'单词的数量。通过对输入字符串进行分析,确定每个必要字母的出现次数,并以此为基础计算最终结果。
908

被折叠的 条评论
为什么被折叠?



