hdu-6034-Balala Power!
Balala Power!
时间限制: 4 Sec 内存限制: 128 MB
题目描述
Talented Mr.Tang has n strings consisting of only lower case characters. He wants to charge them with Balala Power (he could change each character ranged from a to z into 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 26 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+7.
输入
For each test case, the first line contains one positive integers n, the number of strings. (1≤n≤100000)
Each of the next n lines contains a string si consisting of only lower case letters. (1≤|si|≤100000,∑|si|≤106)
输出
样例输入
1 a 2 aa bb 3 a ba abc
样例输出
Case #1: 25 Case #2: 1323 Case #3: 18221
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
#include <bits/stdc++.h>
using namespace std; typedef long long LL; const int N = 100020; char str[N]; ///根据在每位出现的次数进行排序,因为位数高的占的权重比较大, void work() if (len > 1) reverse(str, str + len);///倒置数组 for (int j = 0 ; j < len ; ++ j) if (sum[str[j] - 'a'] >= Q) sum[str[j] - 'a'] = sum[str[j] - 'a']%Q; L = max(L, len); ///对每个字母出现的次数进行进位处理,(以26进制) while (num[i][L]) int res = 0, x = 25; for (int i = 25 ; i >= 0 ; -- i) int main() |
hdu-6034-Balala Power!相关推荐
- HDU 6034 - Balala Power! | 2017 Multi-University Training Contest 1
/* HDU 6034 - Balala Power! [ 大数进位,贪心 ] 题意:给一组字符串(小写英文字母),将上面的字符串考虑成26进制数,每个字母分配一个权值,问这组数字加起来的和最大是多少 ...
- HDU 6034 Balala Power!
题目内容 题意:就是给a~z之间的每个字母1个0~25之间的数,即为每个字母的权重(权重的分配依据于每个字母所做的贡献),相当于26进制数.求使所有字符串之和最大的值是多少? 贪心,将所有字母按照所做 ...
- (2017多校训练第一场)HDU - 6034 Balala Power! 贪心
很容易就想到把每个字母的权重都算出来,然后把权重最大的赋值成25,次大的赋值成24......以此类推. 但是字符串长度最大为100000,也就是说一个字母的权重最大是26^100000次方左右,太大 ...
- hdu 6034 B - Balala Power! 贪心
B - Balala Power! 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6034 题面描述 Talented Mr.Tang has n st ...
- HDU 2017 多校联赛 1002 Balala Power!
题目描述 Talented Mr.Tang has n strings consisting of only lower case characters. He wants to charge the ...
- HDU6034 Balala Power!
Balala Power! 这道题的题意就是给你n个字符串,让你对每个字符赋值(0~25)(注意,每种字符只能赋一个值),然后让你求这些字符的26进制的和的最大值,并且用十进制输出这个最大值. 解释一 ...
- hdu6304 Balala Power!
http://acm.hdu.edu.cn/showproblem.php?pid=6034 基本的想法是统计出每个字母的贡献,然后贡献最小的就把更小的数字分给他 但这题关键在于贡献太大了,需要取模, ...
- HDU - 4461 The Power of Xiangqi
题目链接 题意 给你两个人的象棋棋子,每个棋子对应一个防御值,如果一个人跑和马不全的话防御值减1.计算那个人的防御最高. AC #include <iostream> #include & ...
- HDU Integer's Power(容斥原理)
题意 求[l,r]的最大指数和(1<=l,r<=10^18) 最大指数和(如64=8^2=4^3=2^6,所以64的最大指数和是6) 题解 很明显我们可以先求出[1,n]的最大指数和,然后 ...
- B - Balala Power!
字符串的字典序可以看作为26进制数字的大小 坑点:大数比较大小需要注意 #include <bits/stdc++.h>using namespace std;typedef long l ...
最新文章
- MasterPage,Page 2者之间事件的执行顺序
- Ext.DomHelper类的使用示例(内容操作)
- Vue2.x 踩坑与总结
- windows下通过eclipse进行远程执行出错:Permission denied:
- smart模版学习笔记一
- Maven学习总结(45)——Maven仓库、将本地Jar包安装到仓库、打可执行的Jar总结
- Collections.sort new Compartor 用法
- 2022年武汉科技大学成人高等学历教育招生简章--学历提升、高起专、专升本
- 安卓pdf取词翻译软件_写论文,你应该知道这些好用的论文翻译软件!
- java二级大纲_计算机二级Java语言程序设计考试大纲
- 内网渗透(一)——本机信息收集
- ws2812b灯带容易坏_WS2812B灯带STC驱动
- 基于51单片机的智能温控风扇(程序+仿真+原理图)
- 判断手机横屏和竖屏方向
- java反序列化成object_java 反序列化输出 object获取为空的问题
- smartsvn的常见问题
- Unity3D windows平台视频录制录屏插件 UnityRecorder
- 借着谈转正感想的时机,再聊聊外企和互联网公司的工作体验
- ABB机器人机器人电路板电压检测法
- 如何“管理”自己的上级