codeforces Gym 100500H H. ICPC Quest 水题
2015-07-27 19:38
459 查看
[b]Problem H. ICPC Quest[/b]
Time Limit: 20 Sec
Memory Limit: 256 MB
[b]题目连接[/b]
http://codeforces.com/gym/100500/attachments
[b]Description[/b]
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.
[b]Input[/b]
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.
[b]Output[/b]
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.
[b]Sample Input[/b]
2 You can be the greatest * You can be the best You can be the King Kong banging on your chest *
[b]Sample Output[/b]
Case 1: Effective Case 2: Ineffective
[b]HINT[/b]
[b]题意[/b]
让你统计频率最高的五个字母,然后看这些字母的值是否超过62
[b]题解:[/b]
统计一下就好了……
[b]代码[/b]
Time Limit: 20 Sec
Memory Limit: 256 MB
[b]题目连接[/b]
http://codeforces.com/gym/100500/attachments
[b]Description[/b]
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.
[b]Input[/b]
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.
[b]Output[/b]
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.
[b]Sample Input[/b]
2 You can be the greatest * You can be the best You can be the King Kong banging on your chest *
[b]Sample Output[/b]
Case 1: Effective Case 2: Ineffective
[b]HINT[/b]
[b]题意[/b]
让你统计频率最高的五个字母,然后看这些字母的值是否超过62
[b]题解:[/b]
统计一下就好了……
[b]代码[/b]
#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\n",cas); else printf("Case %d: Ineffective\n",cas); } }
相关文章推荐
- IOS--UI 电影列表纯代码
- EasyUI TextBox的keypress
- iOS UI篇 学习笔记 UILabel
- PAT (Advanced Level) 1056. Mice and Rice (25) 模拟比赛,用queue辅助
- 初学iOS UI 用于交流与学习
- UESTC 94 Bracket Sequence(线段树的区间更新)
- PAT 1099. Build A Binary Search Tree (30)
- flash builder 配置中如果有中文会报错
- iOS - UI-归档解归档
- POJ 2785 4 Values whose Sum is 0 (对半分解 二分搜索)
- leetcode 060 —— Permutation Sequence
- hdu 5306 Gorgeous Sequence
- Intellij IDEA 14.x 菜单项中Compile、Make和Build的区别
- 【读书笔记】UIWindow-WindowLevel
- 【读书笔记】UIWindow-WindowLevel
- codeforce Gym 100500H ICPC Quest (简单dp)
- Unique Binary Search Trees
- UITableViewRowAction的使用
- html元素li的value属性
- iOS-UI-01 UIWindow UIView