Codecraft-17 and Codeforces Round #391 - A
题目链接:http://codeforces.com/contest/757/problem/A
题意:给定一个字符串,问你从这个字符串中选出一些字符然后重新排序后最多能组成多少个 Bulbasaur
思路:统计每个字符出现的次数即可,然后各个字符串的最小值即为最多的个数
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner; public class Main {
public static final String s="Bulbasr";
public static int cnt[]=new int[s.length()];
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
String str=cin.nextLine();
Arrays.fill(cnt, 0);
for(int i=0;i<str.length();i++){
for(int j=0;j<s.length();j++){
if(str.charAt(i)==s.charAt(j)){
cnt[j]++;break;
}
}
}
int ans=Math.min(Math.min(Math.min(Math.min(Math.min(Math.min(cnt[0], cnt[1]/2), cnt[2]), cnt[3]), cnt[4]/2), cnt[5]), cnt[6]);
out.println(ans);
cin.close();
out.flush();
}
}
Codecraft-17 and Codeforces Round #391 - A的更多相关文章
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)
传送门:http://codeforces.com/contest/757 A题题意是给你一个字符串,让你在里面找到"Bulbasaur"这样的单词有多少个,字符串可以重排列.实际 ...
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)D. Felicity's Big Secret Revealed
题目连接:http://codeforces.com/contest/757/problem/D D. Felicity's Big Secret Revealed time limit per te ...
- vector的哈希值 Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) C
http://codeforces.com/contest/757/problem/C 题目大意:有n个导管,每个体育馆有k种神奇宝贝,然后所有的n个体育馆中,一共有m中神奇宝贝.可知,每个神奇宝贝中 ...
- Codeforces Round #391 C. Felicity is Coming!
题目链接 http://codeforces.com/contest/757/problem/C 题意:给你n组数范围在1-m,可进行变换f(x)=y,就是将所有的x全变成y,最后 要满足变化后每组数 ...
- Codecraft-17 and Codeforces Round #391 - C
题目链接:http://codeforces.com/contest/757/problem/C 题意:给定n个gym和m个Pokemon的类型,然后给你每个gym内的Pokemon未进化之前的类型, ...
- Codecraft-17 and Codeforces Round #391 - B
题目链接:http://codeforces.com/contest/757/problem/B 题意:给定n个数字,问最多能选个多少个数字使得选出来的数字的gcd!=1. 思路:由于数字最大为1e5 ...
- Codeforces Round #391 div1 757F (Dominator Tree)
首先先膜杜教orz 这里简单说一下支配树的概念 支配树是对一个有向图来讲的 规定一个起点s,如果s到v的路径上必须经过某些点u,那么离s最近的点u就是v的支配点 在树上的关系就是,v的父亲是u. 一般 ...
- Codeforces Round #391 A B C D E
A. Gotta Catch Em' All! 题意 从给定的字符串中选取字符,问可构成多少个\(Bulbasaur\) // 想到柯南里一些从报纸上剪汉字拼成的恐吓信_(:з」∠)_ Code #i ...
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) C
It's that time of the year, Felicity is around the corner and you can see people celebrating all aro ...
随机推荐
- 【leetcode】1042. Flower Planting With No Adjacent
题目如下: You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flow ...
- 正则化的L1范数和L2范数
范数介绍:https://www.zhihu.com/question/20473040?utm_campaign=rss&utm_medium=rss&utm_source=rss& ...
- linux运维、架构之路-数据库迁移
一.wordpress搭建 1.wordpress下载部署 cd /server/tools/ wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN. ...
- iconfont的三种使用方式
这篇文章主要介绍了iconfont的三种使用方式,需要的朋友可以参考下 在我们项目中经常要使用到iconfont,在此我们使用阿里巴巴矢量库提供的icon图标,此图标库足够为我们提供大量的图标,我 ...
- [CF846B]Math Show题解
暴力一下就好啦! 枚举一下一共做多少次任务,剩下的时间将子任务排序,从头开始能取多少取多少就行了. 贴个代码 #include <cstdio> #include <algorith ...
- string 、char* 、 char []的转换
1.string->char* (1)data string s = "goodbye"; const char* p=str.data(); (2)c_str() stri ...
- 解决Windows2003 Server终端服务120天限制
用过windows server 2003做服务器的人都知道,windows2003的性能安全性比以前的windows版本高出很多,但是也带来很多麻烦.其中服务器最重要的远程管理“终端服务”居然要求授 ...
- Swap——hdu 2819
Swap Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 5 October
POJ2676 Sudoku 位运算 + 搜索.更好的优化方法:方案数最小的空格先填. 把某一位 置为 0:a &=~ (1<<n) 把某一位 置为 1:a |= (1<&l ...
- java并发编程如何预防死锁
在java并发编程领域已经有技术大咖总结出了发生死锁的条件,只有四个条件都发生时才会出现死锁: 1.互斥,共享资源X和Y只能被一个线程占用 2.占有且等待,线程T1已经取得共享资源X,在等待共享资源Y ...