【codeforces 757A】Gotta Catch Em' All!
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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”.
【题目链接】:http://codeforces.com/contest/757/problem/A
【题解】
统计那个字符串中出现的字母(设为集合S)出现的个数;
出现两次(在那个字符串中)的最后(对统计后的结果)除2处理;
然后记录S集合中出现次数最少的字母出现的次数就是答案;
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int MAXN = 1e5+10;
char s[MAXN];
map <char,int> dic;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
scanf("%s",s+1);
int len = strlen(s+1);
rep1(i,1,len)
dic[s[i]]++;
dic['u']/=2;
dic['a']/=2;
string s2 = "Bulbasaur";
int mi = 21e8;
len = s2.size();
rep1(i,0,len-1)
mi = min(mi,dic[s2[i]]);
printf("%d\n",mi);
return 0;
}
【codeforces 757A】Gotta Catch Em' All!的更多相关文章
- 757A Gotta Catch Em' All!
A. Gotta Catch Em' All! time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
随机推荐
- POJ Oulipo(KMP模板题)
题意:找出模板在文本串中出现的次数 思路:KMP模板题 #include<cstdio> #include<cstring> #include<cmath> #in ...
- python-string中部分string替换
今天遇到一个问题,就是需要把 “/home/zhangshuli/32_kk/” 中的32_kk 替换成为 52_kk 然后就在网上找方法,刚开始尝试的方法是 aaa = "/home/zh ...
- h5背景
1.背景属性复习: background-image background-color background-repeat background-position background-attachm ...
- HDU 4508 湫湫系列故事——减肥记I (2013腾讯编程马拉松初赛第一场)
http://acm.hdu.edu.cn/showproblem.php?pid=4508 题目大意: 给定一些数据. 每组数据以一个整数n开始,表示每天的食物清单有n种食物. 接下来n行,每行两 ...
- FZU《C语言程序综合设计》
一年前的玩意. 老是有人找我要..一年前写得这么搓都不敢拿出来.... 但是好多人要啊.....直接发blog,省得下次还要发压缩文件.. 就不要吐槽我代码烂了,我也觉得很烂,至少现在看来确实很烂.. ...
- APP功能点测试
一.移动互联网特点: 1,用户体验至上:精准的用户体验 2,核心竞争力:市场占有率和业务创新能力 3,营销模型:通过口碑传播吸引客户,随之参与互动(如分享等,对接口测试要求高) 二.项目特点: 1,开 ...
- centos7 分区满了,分析哪个目录或文件占用空间-小叶-51CTO博客
原文:centos7 分区满了,分析哪个目录或文件占用空间-小叶-51CTO博客 du -sh 例如: [root@zabbix ~]# du -sh /var/* 0 /var/adm 132M / ...
- 全选或者单选checkbox的值动态添加到div
图片.png <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...
- Linux下的lds链接脚本简介(三)
八. 内存区域命令 在默认情形下,连接器可以为section在程序地址空间内分配任意位置的存储区域.并通过输出section描述的> REGION属性显示地将该输出section限定于在程序地址 ...
- YASM User Manual
This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...