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=;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************* int a[];
char s[maxn];
int main()
{
//この戦い终わった、故郷に帰って结婚するだん!!! ??\
cout<<"please hack me"<<endl;
int t=read();
for(int cas=;cas<=t;cas++)
{
memset(a,,sizeof(a));
gets(s);
for(int i=;i<strlen(s);i++)
{
if(s[i]<='z'&&s[i]>='a')
a[s[i]-'a']++;
}
int num=inf;
num=min(num,a['g'-'a']-);
num=min(num,a['o'-'a']/);
num=min(num,a['d'-'a']);
num=min(num,a['m'-'a']);
num=min(num,a['r'-'a']);
num=min(num,a['n'-'a']/);
num=min(num,a['i'-'a']);
printf("Case #%d: %d\n",cas,num);
}
}

CDOJ 486 Good Morning 傻逼题的更多相关文章

  1. BZOJ-1625 宝石手镯 01背包(傻逼题)

    傻逼题,懒得打,复制蛋蛋的.. 1625: [Usaco2007 Dec]宝石手镯 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1076 Solved: ...

  2. Codeforces Gym 100338I TV Show 傻逼DFS,傻逼题

    Problem I. TV ShowTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  3. BZOJ 2222: [Cqoi2006]猜数游戏【神奇的做法,傻逼题,猜结论】

    2222: [Cqoi2006]猜数游戏 Time Limit: 20 Sec  Memory Limit: 259 MBSubmit: 604  Solved: 260[Submit][Status ...

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

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

  5. BZOJ4644: 经典傻逼题【线段树分治】【线性基】

    Description 这是一道经典傻逼题,对经典题很熟悉的人也不要激动,希望大家不要傻逼. 考虑一张N个点的带权无向图,点的编号为1到N. 对于图中的任意一个点集 (可以为空或者全集),所有恰好有一 ...

  6. Codeforces Round #303 (Div. 2) D. Queue 傻逼题

    C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/probl ...

  7. BZOJ2761: [JLOI2011]不重复数字【set】【傻逼题】

    Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...

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

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

  9. 【题解】 bzoj2435: [Noi2011]道路修建 (傻逼题)

    bzoj2435,懒得复制,戳我戳我 Solution: 模拟即可(有点傻逼啊 Code: //It is coded by Ning_Mew on 5.13 #include<bits/std ...

随机推荐

  1. jquery插件——日历控件

    今天在网上有看到一个jquery插件——日历控件,不过之前也在柯乐义的网站上看到了(http://keleyi.com/ 推荐下) 这个插件看着比较大气,所以干脆也分享下,以后自己也好用一点儿 1.页 ...

  2. Java 单元测试(Junit)

    在有些时候,我们需要对我们自己编写的代码进行单元测试(好处是,减少后期维护的精力和费用),这是一些最基本的模块测试.当然,在进行单元测试的同时也必然得清楚我们测试的代码的内部逻辑实现,这样在测试的时候 ...

  3. MYSQL内存

    全局内存(BASE MEMORY) 线程内存(MEMORY PER CONNECTION) max_conecctions:整个 MySQL 允许的最大连接数; max_user_connection ...

  4. 向Oracle中插入记录时,出现“Oracle.DataAccess.Client.OracleException ORA-00933 ”错误

    错误信息的弹出框

  5. [Everyday Mathematics]20150207

    求极限 $$\bex \lim_{x\to+\infty}\sex{\sqrt{x+\sqrt{x+\sqrt{x^\al}}}-\sqrt{x}},\quad\sex{0<\al<2}. ...

  6. ThinkAndroid是简洁,快速的进行Android应用程序的框架

    ThinkAndroid简介ThinkAndroid是一个免费的开源的.简易的.遵循Apache2开源协议发布的Android开发框架,其开发宗旨是简单.快速的进行Android应用程序的开发,包含A ...

  7. C# Code for Downloading Stock Symbols z

    http://www.jarloo.com/download-stock-symbols/ If your using C# you can easily get the XML data using ...

  8. Long Dominoes(ZOJ 2563状压dp)

    题意:n*m方格用1*3的方格填充(不能重叠)求有多少种填充方法 分析:先想状态,但想来想去就是觉得不能覆盖所有情况,隔了一天,看看题解,原来要用三进制 0 表示横着放或竖放的最后一行,1表示竖放的中 ...

  9. Handling HTTP 404 Error in ASP.NET Web API

            Introduction: Building modern HTTP/RESTful/RPC services has become very easy with the new AS ...

  10. 一行命令实现Android自动关机

    前几天晚上失眠,实在睡不着觉,于是想用Nexus7听一听小野丽莎的歌,在安静祥和之中睡去(怎么感觉有点...)但是不能让平板总是这么循环播放吧(屋里吐槽Google Play Music),所以在平板 ...