2012 Asia Chengdu Regional Contest Problem A
呵呵!
Browsing History
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1740 Accepted Submission(s): 964
Problem Description
One day when you are going to clear all your browsing history, you come up with an idea: You want to figure out what your most valued site is. Every site is given a value which equals to the sum of ASCII values of all characters in the URL. For example aa.cc has value of 438 because 438 = 97 + 97 + 46 + 99 + 99. You just need to print the largest value amongst all values of sites.
Things are simplified because you found that all entries in your browsing history are of the following format: [domain], where [domain] consists of lower-case Latin letters and “.” only. See the sample input for more details.
Things are simplified because you found that all entries in your browsing history are of the following format: [domain], where [domain] consists of lower-case Latin letters and “.” only. See the sample input for more details.
Input
There are several test cases.
For each test case, the first line contains an integer n (1 ≤ n ≤ 100), the number of entries in your browsing history.
Then follows n lines, each consisting of one URL whose length will not exceed 100.
Input is terminated by EOF.
For each test case, the first line contains an integer n (1 ≤ n ≤ 100), the number of entries in your browsing history.
Then follows n lines, each consisting of one URL whose length will not exceed 100.
Input is terminated by EOF.
Output
For each test case, output one line “Case X: Y” where X is the test case number (starting from 1) and Y is a number indicating the desired answer.
Sample Input
1
aa.cc
2
www.google.com
www.wikipedia.org
Sample Output
Case 1: 438
Case 2: 1728
Source
Recommend
liuyiding
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <map> 3 #include <queue> 4 #include <vector> 5 #include <string> 6 #include <cstdio> 7 #include <cstring> 8 #include <iostream> 9 #include <algorithm> 10 using namespace std; 11 #define maxn 4005 12 #define ll long long 13 #define INF 0x7fffffff 14 char s[maxn]; 15 int n,m; 16 int main(){ 17 int cas=1; 18 while(~scanf("%d",&m)){ 19 int ma=0; 20 while(m--){ 21 int n=0; 22 scanf("%s",&s); 23 for(int i=0;i<strlen(s);i++)n+=s[i]=='.'?46:s[i]-'a'+97; 24 ma=max(ma,n); 25 } 26 printf("Case %d: ",cas++); 27 printf("%d\n",ma); 28 } 29 return 0; 30 }
浙公网安备 33010602011771号