cf 757A Gotta Catch Em' All! (水题)
来源:互联网 发布:网页文字游戏源码 编辑:程序博客网 时间:2024/05/12 10:43
题目链接:http://codeforces.com/problemset/problem/757/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 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 a single integer, the answer to the problem.
Bulbbasaur
1
F
0
aBddulbasaurrgndgbualdBdsagaurrgndbb
2
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".题意:找出给出的字符串中有多少个Bulbbasaur,注意B要大写
比赛的时候有点脑抽,先判断了B有多少个,其实应该判断Bulbbasaur中个数最少的字符,它的个数就是字答案
代码:
#define _CRT_SBCURE_MO_DEPRECATE #include<iostream> #include<stdlib.h> #include<stdio.h> #include<cmath> #include<algorithm> #include<string> #include<string.h> #include<set> #include<queue> #include<stack> #include<functional> using namespace std;const int maxn = 1000000 + 10;const int INF = 0x3f3f3f3f;typedef long long ll;char s1[20] = "Bulbasaur";char bu[maxn];int B, u, l, b, a, s, r;int main() {while (scanf("%s", bu) != EOF) {int len = strlen(bu);B = u = l = b = a = s = r = 0;for (int i = 0; i < len; i++) {if (bu[i] == 'B')B++;if (bu[i] == 'u')u++;if (bu[i] == 'l')l++;if (bu[i] == 'b')b++;if (bu[i] == 'a')a++;if (bu[i] == 's')s++;if (bu[i] == 'r')r++;}u = u / 2;a = a / 2;if (B <= u && b <= l && B <= b &&B <= a &&B <= s &&B <= u && B <= r)cout << B << endl;else {int minn;minn = min(B, u); minn = min(minn, l);minn = min(minn, l); minn = min(minn, a);minn = min(minn, b); minn = min(minn, s);minn = min(minn, r);cout << minn << endl;}}return 0;}
题意:
- cf 757A Gotta Catch Em' All! (水题)
- codeforces 757 A. Gotta Catch Em' All!
- 【codeforces 757A】Gotta Catch Em' All!
- A. Gotta Catch Em' All!
- Codeforces 757 Gotta Catch Em' All!
- codeforces757A. Gotta Catch Em' All!
- Gotta Catch Em' All!_Codeforces
- Codeforces Round #391 -A. Gotta Catch Em' All!
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A. Gotta Catch Em' All!(水题)
- CF IndiaHack A 水题
- cf#328-A. PawnChess-水题
- Jzzhu and Children - CF 450A 水题
- CF#309-A. Kyoya and Photobooks-水题
- cf#324-A. Olesya and Rodion-水题
- CF#306- A - Two Substrings-水题
- CF 779A Pupils Redistribution 模拟,水题
- CF#805 A. Fake NP(水题)
- CF#808 A. Lucky Year(水题)
- 关于Fragment中的onAttach方法
- 周笔记(11/52)
- CCF CSP试题 201312-3最大的矩形
- Hibernate13
- cmd命令之跳转目录
- cf 757A Gotta Catch Em' All! (水题)
- 内核驱动的静态加载
- 计算机科学与技术学习心得
- Android新特性介绍,ConstraintLayout完全解析
- 如何修改element.style内联样式;
- A
- Appium+Python+Genymotion,菜鸟demo时遇到的坑
- 简单对继承总结
- Project Euler Problem1-5