首页 > ACM题库 > HDU-杭电 > HDU 4464-Browsing History[解题报告]HOJ
2015
07-16

HDU 4464-Browsing History[解题报告]HOJ

Browsing History

问题描述 :

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.

输入:

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.

输出:

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.

样例输入:

1
aa.cc
2
www.google.com
www.wikipedia.org

样例输出:

Case 1: 438
Case 2: 1728

/*
分析:
    水题(2012成都站签到题)。

                                   2012-11-24
*/

#include"stdio.h"
#include"string.h"
#include"stdlib.h"
int main()
{
	int Case=1;
	int n;
	int i;
	char str[111];
	int ans;
	while(scanf("%d",&n)!=-1)
	{
		ans=0;
		int temp;
		while(n--)
		{
			temp=0;
			scanf("%s",str);
			for(i=0;str[i];i++)	temp+=str[i];
			if(temp>ans)	ans=temp;
		}
		printf("Case %d: %d\n",Case++,ans);
	}
	return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

参考:http://blog.csdn.net/ice_crazy/article/details/8220827