CDOJ 486 Good Morning 傻逼题
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 傻逼题的更多相关文章
- BZOJ-1625 宝石手镯 01背包(傻逼题)
傻逼题,懒得打,复制蛋蛋的.. 1625: [Usaco2007 Dec]宝石手镯 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1076 Solved: ...
- Codeforces Gym 100338I TV Show 傻逼DFS,傻逼题
Problem I. TV ShowTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...
- BZOJ 2222: [Cqoi2006]猜数游戏【神奇的做法,傻逼题,猜结论】
2222: [Cqoi2006]猜数游戏 Time Limit: 20 Sec Memory Limit: 259 MBSubmit: 604 Solved: 260[Submit][Status ...
- [BZOJ]4644: 经典傻逼题
某天我觉得一切题目都是那么不可做,于是百度了一下"傻逼题"-- 题目大意:对于图中的任意一个点集(可以为空或者全集),所有恰好有一个端点在这个点集中的边组成的集合被称为割.一个割的 ...
- BZOJ4644: 经典傻逼题【线段树分治】【线性基】
Description 这是一道经典傻逼题,对经典题很熟悉的人也不要激动,希望大家不要傻逼. 考虑一张N个点的带权无向图,点的编号为1到N. 对于图中的任意一个点集 (可以为空或者全集),所有恰好有一 ...
- Codeforces Round #303 (Div. 2) D. Queue 傻逼题
C. Woodcutters Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/probl ...
- BZOJ2761: [JLOI2011]不重复数字【set】【傻逼题】
Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 ...
- UVA11019 Matrix Matcher【hash傻逼题】【AC自动机好题】
LINK1 LINK2 题目大意 让你在一个大小为\(n*m\)的矩阵中找大小是\(x*y\)的矩阵的出现次数 思路1:Hash hash思路及其傻逼 你把一维情况扩展一下 一维是一个bas,那你二维 ...
- 【题解】 bzoj2435: [Noi2011]道路修建 (傻逼题)
bzoj2435,懒得复制,戳我戳我 Solution: 模拟即可(有点傻逼啊 Code: //It is coded by Ning_Mew on 5.13 #include<bits/std ...
随机推荐
- 安卓dalvik和art区别
Dalvik模式像是一台折叠自行车,每次骑之前都要组装后才能上路.而ART模式就是一个已经装好的自行车,直接就能上车走人.所以ART模式在效率上肯定是要好于Dalvik. 通过以上这种表格,我们可以直 ...
- 两个android程序间的相互调用(apk互调)
通常我们用到的只是activity之间的互相跳转和调用,很少会用到apk级别的互相调用. 往往在一些应用上会用到,比如一个支付系统,可能会有很多的一系列的程序调用到:彩票系统.订票系统.团购网……全部 ...
- [Everyday Mathematics]20150106
(1). 设 $f\in C[0,T]$, $g$ 是 $T$-周期函数, 试证: $$\bex \vlm{n}\int_0^T f(x)g(nx)\rd x=\frac{1}{T}\int_0^T ...
- strcpy函数和strncpy函数的区别
strcpy函数和strncpy函数的原型介绍在我的另一篇文章中介绍了,见strcpy,strncpy,strlen等函数原型 strcpy:字串复制 原型:char *strcpy(char *de ...
- ASP.NET常用技巧方法代码断
1. 打开新的窗口并传送参数:传送参数:response.write("<script>window.open('*.aspx?id="+this.DropDownLi ...
- J2SE7规范_2013.2_类
8.1 类的定义 包括普通类和枚举类,枚举(略) 下面都是指普通类: public只能用于外部类,成员类,不能用于局部类,匿名类 protected和private用于成员类时(待解) sta ...
- 详细理解 > /dev/null 2>&1
0:表示键盘输入(stdin) 1:表示标准输出(stdout),系统默认是1 2:表示错误输出(stderr) "command >/dev/null 2>&1 &am ...
- ERROR (ClientException)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABPwAAABCCAIAAABM0F+3AAAgAElEQVR4nO2d+29d13Xn7y+xyMvLty
- asp.net mvc 实体类成员变量标识示例
检查不能为空 [Required] public string ID { get; set; } 检查最大长度 [StringLength(36, ErrorMessage = "长度不可超 ...
- Tomcat线程池,更符合大家想象的可扩展线程池
因由 说起线程池,大家可能受连接池的印象影响,天然的认为,它应该是一开始有core条线程,忙不过来了就扩展到max条线程,闲的时候又回落到core条线程,如果还有更高的高峰,就放进一个缓冲队列里缓冲一 ...