码迷,mamicode.com
首页 > 其他好文 > 详细

第一场 A Balala Power!

时间:2017-07-31 13:21:19      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:note   二维数组   leading   排序   tps   -o   UI   xmlns   rac   

技术分享

Talented Mr.Tang has nn strings consisting of only lower case characters. He wants to charge them with Balala Power (he could change each character ranged from a to zinto each number ranged from 0 to 25, but each two different characters should not be changed into the same number) so that he could calculate the sum of these strings as integers in base 2626 hilariously. 

Mr.Tang wants you to maximize the summation. Notice that no string in this problem could have leading zeros except for string "0". It is guaranteed that at least one character does not appear at the beginning of any string. 

The summation may be quite large, so you should output it in modulo 109+7109+7.

InputThe input contains multiple test cases. 

For each test case, the first line contains one positive integers nn, the number of strings. (1n100000)(1≤n≤100000) 

Each of the next nn lines contains a string sisi consisting of only lower case letters.(1|si|100000,|si|106)(1≤|si|≤100000,∑|si|≤106) 
OutputFor each test case, output " Case #xx: yy" in one line (without quotes), where xxindicates the case number starting from 11 and yy denotes the answer of corresponding case.Sample Input

1
a
2
aa
bb
3
a
ba
abc

Sample Output

Case #1: 25
Case #2: 1323
Case #3: 18221

题目大意:给出n行小写字母组成的字符串,字符串的每个字母有26进制表示并且字符串的第一个字符不能为0,求这n行字符串相加的和是多少??

解题思路:首先使用二维数组记录字符串的位置上的字符和一维数组第一个字符进行统计,然后用二维数组对结构体进行排序,从大到小将不是前导的字符赋值为0,从小到大对不是0的字符由25开始往0对字符进行赋值,最后对于二维数组进行计数,打印结果即可。

AC代码:

 

第一场 A Balala Power!

标签:note   二维数组   leading   排序   tps   -o   UI   xmlns   rac   

原文地址:http://www.cnblogs.com/wang-ya-wei/p/7262466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!