zoukankan      html  css  js  c++  java
  • Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A

    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 }
  • 相关阅读:
    12
    Kafka设计解析(二)- Kafka High Availability (上)
    Apache kafka 工作原理介绍
    Kafka设计解析(一)- Kafka背景及架构介绍
    【转载】MySQL之权限管理
    【转载】漫谈HADOOP HDFS BALANCER
    【转载】HDFS 上传文件不均衡和Balancer太慢的问题
    【转载】mysql binlog日志自动清理及手动删除
    【转】Typora极简教程
    更新Linux服务器时间
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/7495025.html
Copyright © 2011-2022 走看看