• CodeForces757A


    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 //2017.01.18
     2 #include <iostream>
     3 #include <cstdio>
     4 #include <cstring>
     5 
     6 using namespace std;
     7 
     8 const int inf = 0x3f3f3f3f;
     9 int book[100];
    10 
    11 int main()
    12 {
    13     string str;
    14     string bul = "Bulbbasaur";
    15     while(cin >> str)
    16     {
    17         memset(book, 0, sizeof(book));
    18         for(int i = 0; i < str.length(); i++)
    19               book[str[i]]++;
    20         book['u']/=2;
    21         book['a']/=2;
    22         int ans = inf;
    23         for(int i = 0; i < bul.length(); i++)
    24               if(ans > book[bul[i]])
    25                   ans = book[bul[i]];
    26         cout<<ans<<endl;
    27     }
    28 
    29     return 0;
    30 }
  • 相关阅读:
    11 改进版通过队列实现一个生产者消费者模型
    13 精进版SVIP版通过队列实现一个生产者消费者模型
    12 再次改进版通过队列实现一个生产者消费者模型
    31 进程
    join方法
    30 进程 线程
    进程传参方式和创建方式2
    设计模式 单例模式
    设计模式 抽象工厂模式
    设计模式 简单工厂模式
  • 原文地址:https://www.cnblogs.com/Penn000/p/6298136.html
Copyright © 2020-2023  润新知