CSU-ACM2019寒假训练1-J - 真的简单题

这个题目就是水题,一道模拟题在输入时判断即可(虽然水,但是还是有必要练习自己的码力),不过自己做的时候被第一个样例给坑了,以为这个就是判断的 ̄へ ̄
题目:
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. .si∈{a,b,…z,A,B,…Z}.

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

日常翻译:╰( ̄ω ̄o)
Bash希望有一天能成为Pokemon master。虽然他喜欢很多Pokemon,但他最喜欢的还是Bulbasaur。很快,事情开始变得严肃起来,他的这种痴迷变成了痴迷。因为他还太小,不能出去捉布巴瑟,所以他想出了自己捉布巴瑟的办法。

他每天都上报纸的头版。他每次从报纸头版的任何地方剪下一个字母,组成“Bulbasaur”(没有引号),并把它贴在墙上。Bash非常讲究大小写——“Bulbasaur”的第一个字母必须是大写的,其余字母必须是小写的。这样做,他认为他抓住了一只巴尔巴苏尔。然后他在报纸的左边重复这一步骤。他一直这样做,直到报纸上不可能出现“Bulbasaur”这个词。

根据报纸头版上的文字,你能告诉我他今天要找到多少"Bulbasaur"吗?
注意:大写和小写字母被认为是不同的。

输入
输入包含一行包含一个字符串s(1≤|s|≤105)——报纸的头版上的文字没有空格和标点符号。|s|是字符串s的长度。字符串s包含小写和大写的英文字母,即∈{a,b,…z,A,B,…Z}.

输出
输出一个整数,问题的答案。

提示:
在第一种情况下,你可以选择:Bulbbasaur.
在第二种情况下,根本没有办法选出一个Bulbbasaur.
在第三种情况下,您可以将字符串重新排列到BulbasaurBulbasauraddrgndgddgargndbb,以获得两个单词“Bulbasaur”。

思路:就是输入的时候将单词里面的每个字母的个数记录一下,分别能构成多少个单词,然后排序,输出最小的,即所有都满足的,就是能够构成单词的个数。

代码如下:

#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
char s;
int ss[7]={0};
int a,b,c;
a=b=c=0;
while(scanf("%c",&s)!=EOF&&s!='\n')
{
   if(s=='B')
     ss[0]++;
   else if(s=='u'&&a==0)
    a=1;
   else if(s=='u'&&a==1)
    { 
      ss[1]++;
      a=0;
    }
   else if(s=='l')
   ss[2]++;
   else if(s=='b')
   ss[3]++;
   else if(s=='a'&&c==0)
   c=1;
   else if(s=='a'&&c==1)
    {
      ss[4]++;
      c=0;
    }
   else if(s=='s')
   ss[5]++;
   else if(s=='r')
   ss[6]++;
}
sort(ss,ss+7);
printf("%d",ss[0]);
return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值