zoukankan      html  css  js  c++  java
  • 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=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
    ",cas,num);
        }
    }
  • 相关阅读:
    有向图的十字链表存储表示 以及相关操作(包括增加弧、删除弧、删除顶点等)
    数据结构学习笔记—图---图的连通性、顶点间的路径
    解决Vue父路由进入子路由选中样式消失的问题
    解决vue页面刷新,数据丢失
    解决PHP接收不到axios的POST的传参方式
    rem理解及应用【笔记】
    JS基础(学习笔记)
    css中的小技巧
    css中文单行、多行超出省略号和英文换行(学习笔记)
    关于JS(原生js+jq)中获取、设置或者删除元素属性和获取元素值
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4678380.html
Copyright © 2011-2022 走看看