zoukankan      html  css  js  c++  java
  • codeforces Gym 100500H H. ICPC Quest 水题

    Problem H. ICPC Quest
    Time Limit: 20 Sec

    Memory Limit: 256 MB

    题目连接

    http://codeforces.com/gym/100500/attachments

    Description

    Coach Fegla has invented a song effectiveness measurement methodology. This methodology in simple English means count the frequency of each character of the English letters [A-Z] in the given song (case insensitive). Get the top 5 characters with the highest frequencies, if 2 characters have the same frequency choose the one which is lexicographically larger. Sum up the indexes of these characters where the index of A is 0, index of B is 1, ..., index of of Z = 25. If this sum exceeds 62 print "Effective"otherwise print "Ineffective"without the quotes.

    Input

    The first line will be the number of test cases T. Each test case will consist of a series of words consisting only of upper or lower case English letters. Each test case ends with a line containing only "*"without the double quotes. Each word consists of a minimum of 1 letter and a max of 20 letters. The number of words in each test case will be a max of 20,000.

    Output

    For each test case print a single line containing: Case x: y x is the case number starting from 1. y is is the required answer either "Effective"or "Ineffective"without the quotes.

    Sample Input

    2 You can be the greatest * You can be the best You can be the King Kong banging on your chest *

    Sample Output

    Case 1: Effective Case 2: Ineffective

    HINT

    题意

    让你统计频率最高的五个字母,然后看这些字母的值是否超过62

    题解

    统计一下就好了……

    代码

    #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;
    }
    //*************************************************************************************
    
    struct node
    {
        int x,y;
    };
    bool cmp(node a,node b)
    {
        if(a.x==b.x)
            return a.y>b.y;
        return a.x>b.x;
    }
    node a[50];
    string s;
    int main()
    {
        int t=read();
        for(int cas=1;cas<=t;cas++)
        {
            memset(a,0,sizeof(a));
            for(int i=0;i<26;i++)
                a[i].y=i;
            while(cin>>s)
            {
                if(s[0]=='*')
                    break;
                for(int i=0;i<s.size();i++)
                {
                    if(s[i]>='a'&&s[i]<='z')
                        a[s[i]-'a'].x++;
                    if(s[i]>='A'&&s[i]<='Z')
                        a[s[i]-'A'].x++;
                }
            }
            sort(a,a+26,cmp);
            int sum=0;
            for(int i=0;i<5;i++)
            {
                if(a[i].x!=0)
                    sum+=a[i].y;
            }
            if(sum>62)
                printf("Case %d: Effective
    ",cas);
            else
                printf("Case %d: Ineffective
    ",cas);
        }
    }
  • 相关阅读:
    E
    牛客比赛—身体训练
    前缀和例题
    欧拉函数模板
    3.30训练题
    poj1321棋盘问题
    记set学习
    B. K-th Beautiful String
    codeforces1293C
    LightOJ 1370 Bi-shoe and Phi-shoe
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4681038.html
Copyright © 2011-2022 走看看