The beauty of the name

Source: Internet
Author: User

1 //12345.cpp:defines the entry point for the console application.2 //3 4#include"stdafx.h"5 6#include <iostream>7#include <string>8#include <algorithm>9#include <vector>Ten  One using namespacestd; A  - intMainvoid) - { the     intN; -      -      while(cin>>N) -     { +          -         int*p =New int[N]; +         stringstr; A          for(intj=0; j<n;++j) at         { -Cin>>str; -vector<int> Hash ( -,0); -              for(intI=0; i < str.length (); + +i) -             { -hash[str[i]-'a']++; in             } - sort (Hash.begin (), Hash.end ()); top[j]=0; +             intCount= -; -              for(vector<int>::iterator It=hash.end ()-1; it >= Hash.begin ();--it) the             { *p[j]=p[j]+ (count--) * (*it); $             }Panax Notoginseng         } -          for(intk=0; k<n;++k) the         { +cout<<p[k]<<Endl; A         } the         Delete[] p; +     } -  $     return 0; $}

Describe

Give a name that consists of 26 strings, which defines the "beauty" of the string as the sum of all its letters "beauty".
Each letter has a "pretty degree", ranging from 1 to 26. No two letters have the same "beauty degree". Letters Ignore case.
Give multiple names to calculate the maximum possible "beauty" for each name.

Knowledge points String
Run time limit 0M
Memory limit 0
Input

An integer n, followed by n names

n A string, each representing a name

Output

Each name may be the most beautiful degree

Sample input 2 Zhangsan Lisi
Sample output 192 101

The beauty of the name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.