Gotta Catch Em' All!

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

C语言版本一

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	char str[100010] ;
	scanf("%s",&str);
	int i,j;
	char bstr[10]="Bulbasaur";
	int bstrnum[9]={0,0,0,0,0,0,0,0,0};
	for(i=0;i<9;i++){
		for(j=0;j<strlen(str);j++){
			if(bstr[i]==str[j])bstrnum[i]+=1;
		}
	}
	bstrnum[1]/=2;
	bstrnum[4]/=2;
	bstrnum[6]/=2;
	bstrnum[7]/=2;
	int min=bstrnum[0];
	for(i=1;i<9;i++){
		
			if(bstrnum[i]<min)min=bstrnum[i];
	
	}
	printf("%d\n",min);
	return 0;
}
全部评论

相关推荐

今天 11:11
已编辑
Imperial College London Java
汇丰科技 oc 18*12 + 年终
点赞 评论 收藏
分享
AI牛可乐:哇,听起来你遇到了什么挑战呢!🐮牛可乐在这里,虽然小,但是勇敢又聪明,想听听你的具体情况哦!如果你愿意的话,可以点击我的头像给我私信,我们可以一起想办法应对挑战,好不好呀?🌟🎉
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务