UESTC 486 Good Morning (水题+坑!)
题意:给你一行字符串,让你找其中蕴含的“good morning"的次数。
析:看起来很水么,多简单,只有统计一下其中字母的出现的次数,然后除以相应的个数。
但是很不幸的是WA,而且是在test1,说明你样例都没过应该。这就是题的坑。
1.坑是这个空格也算一部分,第二个样例可能最后一个空格没打上,所以误导了。但是也这样也是WA。
为什么呢?因为还少考虑了一种情况。
2.“good morningood morning"这个是算2个的,也就是说g这个字母要特殊考虑,也就是g只要比次数多1就行。
代码如下:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#include <map> using namespace std;
const int maxn = 10000 + 10;
char s[maxn];
int a[30]; int main(){
int T; cin >> T;
getchar();
for(int kase = 1; kase <= T; ++kase){
gets(s);
int len = strlen(s);
memset(a, 0, sizeof(a));
int t = 0;
for(int i = 0; i < len; ++i)
if(' ' == s[i]) ++t;
else if(s[i] >= 'a') ++a[s[i]-'a']; int m = a['d'-'a'];
m = min(m, a['i'-'a']);
m = min(m, a['r'-'a']); m = min(m, a['o'-'a']/3);
m = min(m, a['m'-'a']); m = min(m, a['n'-'a']/2);
m = min(m, t); m = min(m, a['g'-'a']-1);
printf("Case #%d: %d\n", kase, m);
}
return 0;
}
UESTC 486 Good Morning (水题+坑!)的更多相关文章
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
- HDU 5832 A water problem (带坑水题)
A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...
- Acdream 1111:LSS(水题,字符串处理)
LSS Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others) SubmitStati ...
- fzuoj Problem 2182 水题
http://acm.fzu.edu.cn/problem.php?pid=2182 Problem 2182 水题 Accept: 188 Submit: 277Time Limit: 100 ...
- cdoj 26 遮挡判断(shadow) 水题
遮挡判断(shadow) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...
- cdoj 24 8球胜负(eight) 水题
8球胜负(eight) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- 2019浙大校赛--J--Extended Twin Composite Number(毒瘤水题)
毒瘤出题人,坑了我们好久,从基本的素数筛选,到埃氏筛法,到随机数快速素数判定,到费马小定理,好好的水题做成了数论题. 结果答案是 2*n=n+3*n,特判1,2. 以下为毒瘤题目: 题目大意: 输入一 ...
- HDU--Elevator(水题)
Elevator nid=24#time"> Time Limit: 1000ms Memory limit: 32768K 有疑问?点这里^_^ 题目描写叙述 The high ...
随机推荐
- PL/SQL Developer安装教程以及汉化包安装教程
一.安装PL/SQL 1.百度下载plsql破解版软件,官网只能使用30天 2.双击plsqldev906.exe进行安装,点击 iagree 3.默认是安装在c盘,可以根据自己需要更改安装目录 4. ...
- 在Linux Bash通过上下键快速查找历史命令
在centos 7中 ~/.bashrc 或者Mac中的 ~/.bash_profile 中添加,然后source一下以下内容: if [[ $- == *i* ]] then bind '" ...
- Haskell语言学习笔记(55)Data.Vector
Data.Vector Construction Prelude V> import Data.Vector as V Prelude V> V.empty [] Prelude V> ...
- 软件工程导论复习 如何画系统流程图和数据流图 part2
数据流图(DFD) 数据流图,简称DFD,是SA方法中用于表示系统逻辑模型的一种工具,它以图形的方式描绘数据在系统中流动和处理的过程,由于它只反映系统必须完成的逻辑功能,所以它是一种功能模型.下 ...
- 脱离SVN的控制
在桌面创建一个记事本文件,然后吧这句话复制进去for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn ...
- 数据类型-Series
数据类型-Series Series数据类型由一组数据和数据相关的索引组成,键 -> 值 Series数据类型可视为:一维 带标签 数组 Series基本操作类似数组和字典 Series数据类型 ...
- Python内置类型性能分析
Python内置类型性能分析 timeit模块 timeit模块可以用来测试一小段Python代码的执行速度. class timeit.Timer(stmt='pass', setup='pass' ...
- obstacle
obstacle - 必应词典 美[ˈɑbstək(ə)l]英[ˈɒbstək(ə)l] n.障碍:障碍物:阻碍:绊脚石 网络妨碍:干扰:妨害
- ASP.NET使用ListView数据绑定控件和DataPager实现数据分页显示(二)
使用ListView控件进行修改,删除与添加操作1.页面代码: <asp:ListView ID="lv2" runat="server" onpagep ...
- Py2exe——将python程序变成windows下可执行的exe
一.安装Py2exe 二.定义一个目录,把你的Python文件放在下面,如为AddFileRandom.py文件 然后新建一个go.py文件,放于相同目录下,内容为: from distutils.c ...