C - C HDU - 4464(水题)

C - C HDU - 4464(水题)

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.
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.
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

代码

#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
void fre() { freopen("A.txt","r",stdin), freopen("Ans.txt","w",stdout); }
#define ll long long 
const int mxn = 2e5;
char ar[mxn];

int main()
{
    /* fre(); */
    int n;
    int Case = 1;
    while(~ scanf("%d", &n))
    {
        ll ans = 0;
        for(int i = 1; i <= n; i ++)
        {
            ll sum = 0;
            scanf("%s", ar); 
            int lar = strlen(ar);
            for(int i = 0; i < lar; i ++)
                sum += ar[i];
            ans = max(ans, sum);
        }
        printf("Case %d: %lld\n", Case ++, ans);
    }

    return 0;
}

猜你喜欢

转载自www.cnblogs.com/lql-nyist/p/12742539.html