【CF#757A】Gotta Catch Em' All!
題干:
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.
InputInput 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.?.
OutputOutput a single integer, the answer to the problem.
Examples InputBulbbasaur Output1 InputF Output0 InputaBddulbasaurrgndgbualdBdsagaurrgndbb Output2 NoteIn 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".
解題報告:
????水題不解釋。
ac代碼:
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; const int MAX = 1e5+5; char str[MAX]; int B,u,l,b,a,s,r; int Min(int a,int b,int c,int d,int e,int f,int g) {int cmp[7]={a,b,c,d,e,f,g};return *min_element(cmp,cmp+7); } int main() {scanf("%s",str);int len=strlen(str);for(int i = 0; i<len; i++) {switch (str[i]){case 'B' : B++;break;case 'u' : u++;break;case 'l' : l++;break;case 'b' : b++;break;case 'a' : a++;break;case 's' : s++;break;case 'r' : r++;break;}}a/=2;u/=2;printf("%d\n",Min(B,u,l,b,a,s,r));return 0 ;} //Bulbasaur總結
以上是生活随笔為你收集整理的【CF#757A】Gotta Catch Em' All!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 交行信用卡电话是多少 有问题找客服全搞定
- 下一篇: Apollo进阶课程⑳丨Apollo感知