日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CDOJ 486 Good Morning 傻逼题

發(fā)布時間:2024/4/17 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CDOJ 486 Good Morning 傻逼题 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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

?

題意

讓你重新排列,使得出現(xiàn)最多的goodmorning

題解:

注意goodmorningoodmorning這個數(shù)據(jù),這個數(shù)據(jù)輸出應(yīng)該是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() {//この戦い終わった、故郷に帰って結(jié)婚するだん!!! ??\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);} }

?

轉(zhuǎn)載于:https://www.cnblogs.com/qscqesze/p/4678380.html

總結(jié)

以上是生活随笔為你收集整理的CDOJ 486 Good Morning 傻逼题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。