Good Morning

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.uestc.edu.cn/#/problem/show/486

Description

Sam loves Lily very much that he shows his love to her through all kinds of ways. This morning, Lily received an e-mail from Sam. Lily knows that Sam hided “good morning” in this mail. Lily tried several ways to resort the letters (including the space ' ') so that more “good morning"s could be found. The number of “good morning” appeared in a specified string equals the number of positions from which Lily could see a consecutive string “good morning”.

With so many letters, Lily is about to be dizzy. She asks you to tell her what is the maximum number of “good morning"s appear in this mail after rearranged in some way.

Input

First an integer $T$ ($T \leq 20$), indicates there are $T$ test cases.

Every test case begins with a single line consist of only lowercase letters and space which is at most $1000$ characters.

Output

For every test case, you should output Case #k: first, where $k$ indicates the case number and starts at $1$. Then output an integer indicating the answer to this test case.

Sample Input

2
gninrom doog
ggoooodd mmoorrnniinngg

Sample Output

Case #1: 1
Case #2: 2

HINT

题意

让你重新排列,使得出现最多的goodmorning

题解:

注意goodmorningoodmorning这个数据,这个数据输出应该是2

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=202501;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}
//*************************************************************************************int a[30];
char s[maxn];
int main()
{//この戦い终わった、故郷に帰って结婚するだん!!! ??\cout<<"please hack me"<<endl;int t=read();for(int cas=1;cas<=t;cas++){memset(a,0,sizeof(a));gets(s);for(int i=0;i<strlen(s);i++){if(s[i]<='z'&&s[i]>='a')a[s[i]-'a']++;}int num=inf;num=min(num,a['g'-'a']-1);num=min(num,a['o'-'a']/3);num=min(num,a['d'-'a']);num=min(num,a['m'-'a']);num=min(num,a['r'-'a']);num=min(num,a['n'-'a']/2);num=min(num,a['i'-'a']);printf("Case #%d: %d\n",cas,num);}
}

转载于:https://www.cnblogs.com/qscqesze/p/4678380.html

CDOJ 486 Good Morning 傻逼题相关推荐

  1. [BZOJ]4644: 经典傻逼题

    某天我觉得一切题目都是那么不可做,于是百度了一下"傻逼题"-- 题目大意:对于图中的任意一个点集(可以为空或者全集),所有恰好有一个端点在这个点集中的边组成的集合被称为割.一个割的 ...

  2. UVA11019 Matrix Matcher【hash傻逼题】【AC自动机好题】

    LINK1 LINK2 题目大意 让你在一个大小为\(n*m\)的矩阵中找大小是\(x*y\)的矩阵的出现次数 思路1:Hash hash思路及其傻逼 你把一维情况扩展一下 一维是一个bas,那你二维 ...

  3. 【纪中受难记】——Day11:傻逼题遇上傻逼人

    事先声明,对题目并无恶意中伤,题目承受的痛苦由傻逼本人(我)来承担. 55/50/45/0 1235. 洪水 (Standard IO) Time Limits: 1000 ms  Memory Li ...

  4. [转一好玩的博文]毕业三年,遇见的傻逼公司大盘点

    2019独角兽企业重金招聘Python工程师标准>>> 转一好玩的博文 说明一下,不是列多少条,等于我换到多少公司啊...可能一家公司找出三条出来写,还有一些是朋友的经历,注意区分啊 ...

  5. win这个傻逼系统,高PPI上默认的情况下是放大的,放大了之后逻辑分辨率不跟着放大。

    win这个傻逼系统,高PPI上默认的情况下是放大的,放大了之后逻辑分辨率不跟着放大,我cnmd.得到的桌面坐标都是错误的.

  6. 数据库切换时的一个傻逼的错误。

    前几天帮一个同学简单的写了一个jsp的学员管理系统,当时我问她要用那个数据库,他说mysql,我就用mysql写了一个结果,写好了之后,他又说不是,要用sqlserver我无语了.于是抽出时间来就给他 ...

  7. 为什么在我眼里你是一只傻逼——傻逼“常所用”句型之(3)——“没看过”“但是其中必定”...

    注:被删的第一条回复是 薛非 一犬吠形百犬吠声.不要像个傻逼似的跟风狂吠,我的书你到底看过没有? http://www.zhihu.com/question/23048342/answer/23455 ...

  8. 当发现以前的自己是个傻逼时,该如何面对以后的人生

    昨天偶然又看了一遍<中国合伙人>,当时初到美国的邓超,丢掉了喂小白鼠的工作,在餐馆做杂工时有个老太太对他说:年轻人,你还可以走的更远,而她(老板娘)只能永远在这里.若干年后,邓超和他的基友 ...

  9. 牛逼 装逼 傻逼 的区别

    你是不是一直觉得自己很牛逼?看完下文你就不会这么想了! 牛逼是少数,  装逼是普遍存在的,  傻逼到处都是. 牛逼的男人只有一个女人,  装逼的男人女人很多,  傻逼的女人的男人很多. 牛逼的人不在乎 ...

最新文章

  1. Hinton 新作!越大的自监督模型,半监督学习需要的标签越少
  2. Spring + JDBC + Struts联合开发(实现单表的CRUD)
  3. Leaflet中使用Leaflet.contextmenu插件实现地图上添加鼠标右键菜单
  4. 180904 再卖菜 ccf
  5. [转] Transformer图解
  6. MySQL数据库编译过程
  7. 计算机网络中的基本概念
  8. php properties,PHP ReflectionClass getStaticProperties()用法及代码示例
  9. Xcode C++ and Objective-C refactoring
  10. 电脑常用音频剪辑软件_常用手机视频剪辑软件
  11. NRF24L01无线通信模块使用示例和调试心得总结
  12. JAVA中SSH框架
  13. JavaScript设计模式----装饰者模式
  14. 【计算几何各种小模板总结贴】[不定期更新]
  15. 陈式新架一路八十三式口诀
  16. 轻量级过程改进之项目计划
  17. Android Audio音量设置流程
  18. python判断两个数据集是否存在包含关系
  19. react-native APP图标和名字的配置
  20. 实例讲解鼠绘上色技巧

热门文章

  1. 【Linux网络编程】原始套接字能干什么?
  2. [Qt教程] 第14篇 2D绘图(四)绘制路径
  3. sumif三个条件怎么填_函数SUMIF和SUMIFS
  4. 请求的站点不可用或找不到_80%的500强用企业微信,企业越来越找不到拒绝用它的理由...
  5. 防火墙(13)——实现路由转发功能(1)
  6. php alias 报错,PHP(FastCGI)在Nginx的alias下出现404错误的解决方法
  7. [NOTE] WindowsLinux常用环境变量
  8. QT误修改了系统内的头文件处理
  9. TypeError系列之:TypeError: only size-1 arrays can be converted to Python scalars
  10. ROS学习笔记-ROS语音识别与语音输出[2]