• 757A Gotta Catch Em' All!


    A. Gotta Catch Em' All!
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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<iostream>
     2 using namespace std;
     3 int f[256];
     4 int main(){
     5     string s;
     6     cin>>s;
     7     for(int i=0;i<s.size();i++)
     8         f[s[i]]++;
     9     int ans;
    10     ans=min(f['B'],min(f['u']/2,min(f['l'],min(f['b'],min(f['a']/2,min(f['s'],f['r']))))));
    11     cout<<ans;
    12 }
  • 相关阅读:
    JavaScript控制改变鼠标的形状
    web控件开发系列(四) 自定义控件属性(上)
    web控件开发系列() 基础介绍
    Web前端面试题 Js把URL中的参数解析为一个对象
    节点的操作 创建、添加、移除、移动、复制
    一个sohoto广告弹出页提取时间的Js修改过程
    FireFox支持innerText的方法
    Js 基于html5localStorage方法 制作的 "我的便签本"
    原生JavaScript对CSS进行格式化和压缩
    JavaScript 命名规则 变量命名规则
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6562036.html
Copyright © 2020-2023  润新知