hdu 6034 Balala Power!
Balala Power!
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 3555 Accepted Submission(s): 844
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)
#include <iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<bits/stdc++.h> using namespace std;
const long long mod=1e9+;
struct node
{
int id;
double k;
}a[];
int b[];
long long num[][];
bool vis[];
char ch[];
int n,maxlen; bool cmp(node a,node b)
{
return a.k>b.k;
}
int main()
{
int cas=;
while(~scanf("%d",&n))
{
maxlen=;
memset(num,,sizeof(num));
memset(vis,,sizeof(vis));
for(;n>;n--)
{
scanf("%s",&ch);
int l=strlen(ch);
maxlen=max(maxlen,l);
if (l>) vis[ch[]-'a']=;
for(int i=;i<l;i++)
num[ch[i]-'a'][l-i-]++;
} for(int i=;i<;i++)
{
a[i].id=i; a[i].k=;
for(int j=;j<maxlen;j++)
a[i].k=a[i].k/+num[i][j];
} sort(a,a+,cmp); for(int i=;i>=;i--)
{
if (vis[a[i].id]) continue;
else
{
int cnt=;
for(int j=;j<;j++)
if (j!=i) b[a[j].id]=cnt--;
else b[a[j].id]=;
break;
}
} long long ans=;
for(int i=;i<;i++)
{
long long ret=;
for(int j=;j<maxlen;j++)
{
ans=(ans+num[i][j]*ret*b[i])%mod;
ret=(ret*)%mod;
}
}
printf("Case #%d: %lld\n",++cas,ans);
}
return ;
}
hdu 6034 Balala Power!的更多相关文章
- HDU 6034 - Balala Power! | 2017 Multi-University Training Contest 1
/* HDU 6034 - Balala Power! [ 大数进位,贪心 ] 题意: 给一组字符串(小写英文字母),将上面的字符串考虑成26进制数,每个字母分配一个权值,问这组数字加起来的和最大是多 ...
- 2017 Multi-University Training Contest - Team 1 1002&&HDU 6034 Balala Power!【字符串,贪心+排序】
Balala Power! Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- HDU 6034 Balala Power!(贪心+排序)
Balala Power! Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017ACM暑期多校联合训练 - Team 1 1002 HDU 6034 Balala Power! (字符串处理)
题目链接 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. He ...
- HDU 6034 Balala Power!【排序/进制思维】
Balala Power![排序/进制思维] Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java ...
- HDU 6034 Balala Power! —— Multi-University Training 1
Talented Mr.Tang has nn strings consisting of only lower case characters. He wants to charge them wi ...
- HDU 6034 Balala Power! (贪心+坑题)
题意:给定一个 n 个字符串,然后问你怎么给 a-z赋值0-25,使得给定的字符串看成26进制得到的和最大,并且不能出现前导0. 析:一个很恶心的题目,细节有点多,首先是思路,给定个字符一个权值,然后 ...
- 6034 Balala Power! (17多校)
题目大意:给出的字符串,每个字符建立一种与0-25的对应关系.然后每个字符串看成是一个26进制的数.问能获得的数的总和的最大值.(最后对1e9+7取模). 题目思考:把每个字符的贡献值看做一个26进制 ...
- hdu 6034 B - Balala Power! 贪心
B - Balala Power! 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6034 题面描述 Talented Mr.Tang has n st ...
随机推荐
- mysql服务解压版的安装(5.7)
推荐博客: https://www.cnblogs.com/LxyXY/p/7708016.html
- jquery的prev选择器无效
今天使用jquery操作dom 需要把当前元素的同级元素中前面带有属性a=1的元素筛选出来. 查看api, .prev() 获得匹配元素集合中每个元素紧邻的前一个同辈元素,由选择器筛选(可选). 看 ...
- centos安装oracle客户端
使用centos远程登陆oracle服务器: 下载需要的rpm包: [root@node1 oracle]# lltotal 59872-rw-r--r-- 1 root root 59865008 ...
- 20135302魏静静——linux课程第六周实验及总结
linux课程第六周实验及总结 实验及学习总结 1.进程描述符task_struct数据结构 进程的作用: 将信号.进程间通信.内存管理和文件系统联系起来 操作系统的三大功能: 进程管理.内存管理.文 ...
- javaScript对象与JSON.stringfly(obj)
//接收json对象 var objJson = new Object(); var arr = new Array(); var obj1 = new Object(); obj1.age = 15 ...
- 【前端】javascript中10常用的个小技巧总结
javascript中10常用的个小技巧总结 本文转自:http://www.cnblogs.com/libin-1/p/6756393.html 1. new Set() 可能有人知道ES6中提供了 ...
- 深度学习笔记(一):logistic分类【转】
本文转载自:https://blog.csdn.net/u014595019/article/details/52554582 这个系列主要记录我在学习各个深度学习算法时候的笔记,因为之前已经学过大概 ...
- win10下搭建jz2440v3(arm s3c2440)开发及gdb调试环境【转】
本文转载自:https://blog.csdn.net/newjay03/article/details/72835758 本来打算完全在Ubuntu下开发的,但是水平有限,没有在Ubuntu下找到合 ...
- iOS开发进阶 - 富文本正则替换表情
移动端访问不佳,请访问我的个人博客 最近写项目需要用到富文本解析字符串显示表情,下面是我使用正则替换实现富文本的方式,希望能帮助到大家 先上效果图和demo地址 实现过程中需要用到的知识点 NSReg ...
- vue.js的一些小语法v-for,v-text,v-html,v-on:click
1.Vue的目录结构: ======================================================================================== ...