博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2017 Multi-University Training Contest - Team 1
阅读量:7242 次
发布时间:2019-06-29

本文共 5135 字,大约阅读时间需要 17 分钟。

弱校也不打多校,自己也可以咸鱼嘛。水一水,玩一玩

 

Add More Zero

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 643    Accepted Submission(s): 449

Problem Description
There is a youngster known for amateur propositions concerning several mathematical hard problems.
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between 
0 and (2m1) (inclusive).
As a young man born with ten fingers, he loves the powers of 10 so much, which results in his eccentricity that he always ranges integers he would like to use from 1 to 10k (inclusive).
For the sake of processing, all integers he would use possibly in this interesting problem ought to be as computable as this supercomputer could.
Given the positive integer m, your task is to determine maximum possible integer k that is suitable for the specific supercomputer.
 

 

Input
The input contains multiple test cases. Each test case in one line contains only one positive integer 
m, satisfying 1m105.
 

 

Output
For each test case, output "
Case #xy" in one line (without quotes), where 
x indicates the case number starting from 1 and y denotes the answer of corresponding case.
 

 

Sample Input
1 64
 

 

Sample Output
Case #1: 0 Case #2: 19
 

 

Source
拿数学公式推一推就好了,O(1)的,就是n*log10(2)的下取整
#include 
#include
int main() { int n,k=1; while(~scanf("%d",&n)){ printf("Case #%d: %d\n",k++,(int)(log10(2)*n)); } return 0;}

Balala Power!

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 3268    Accepted Submission(s): 738

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

 

Input
The input contains multiple test cases.
For each test case, the first line contains one positive integers 
n, the number of strings. (1n100000)
Each of the next n lines contains a string si consisting of only lower case letters. (1|si|100000,|si|106)
 

 

Output
For each test case, output "
Case #xy" in one line (without quotes), where 
x indicates the case number starting from 1 and y 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
这个图魔性了,强无敌,其实就是2进制的字符串,假如可以有前导零的话,算下贡献,贡献最大的数是25不就好了,但是不能有前导0的贪心就要后移,自己讨论下并不难,不过这个模拟也不短,等过些日子找个短的代码贴一下
#include
#include
#include
#include
using namespace std;typedef long long ll;const int mod = 1e9+7;const int N = 1e5+5;ll fac[N]= {
1};int ma[27];bool lead[27];char str[N];void init() { for(int i=1; i < N; i++) fac[i]=fac[i-1]*26%mod;}struct node { int cnt[N]; int id; bool operator < (const node &a) const { for(int i = N-1; i >= 0; i--) { if(cnt[i] > a.cnt[i]) return 1; else if(cnt[i] < a.cnt[i]) return 0; else ; } }} a[27];int main() { int n, k = 1; init(); while(~scanf("%d", &n)) { memset(a, 0, sizeof(a)); memset(ma, -1, sizeof(ma)); memset(lead, 0, sizeof(lead)); for(int i = 1; i <= n; i++) { scanf(" %s", str); int len = strlen(str); if(len != 1) lead[str[0]-'a'] = 1; for(int i = 0; i < len; i++) a[str[i]-'a'].cnt[len-i-1]++; } for(int i = 0; i < 26; i++) { for(int j = 0; j < N; j++) { if(a[i].cnt[j] >= 26) { a[i].cnt[j+1] += a[i].cnt[j]/26; a[i].cnt[j] %= 26; } } a[i].id = i; } sort(a, a+26); for(int i = 0; i < 26; i++) ma[a[i].id] = 26-i-1; for(int i = 0; i < 26; i++) if(lead[a[i].id] && ma[a[i].id] == 0) { for(int j = 25; j >= 0; j--) { if(!lead[a[j].id]) { for(int k = 25; k >= j+1; k--) ma[a[k].id] = ma[a[k-1].id]; ma[a[j].id] = 0; break; } } break; } ll ans = 0; for(int i = 0; i < 26; i++) { for(int j = 0; j < N; j++) { ans = (ans+fac[j]*a[i].cnt[j]*ma[a[i].id]%mod)%mod; } } printf("Case #%d: %lld\n", k++, ans); } return 0;}

 

转载于:https://www.cnblogs.com/BobHuang/p/7239401.html

你可能感兴趣的文章
char类型是否有符号与不同编译环境相关
查看>>
移动端切图备忘(别人的)
查看>>
Ubuntu下安装配置VNC远程工具
查看>>
Android Cordova微信插件动态包名处理
查看>>
Java调用Matlab程序
查看>>
angular ng-include 指令的使用
查看>>
Common Lisp通过CFFI调用C动态库
查看>>
Beyond SQLi: Obfuscate and Bypass
查看>>
Spring(二):配置和简单使用
查看>>
Java中的try-catch机制的要点
查看>>
web.xml 中的listener、 filter、servlet 加载顺序及其详解
查看>>
group by,having,where
查看>>
shiro概念(转)
查看>>
Android中attrs.xml
查看>>
Eclipse开启错误“Failed to create the java virtual mach
查看>>
Struts2.3.15.2配置
查看>>
ubuntu 14.04下chrome显示标题乱码问题
查看>>
eclipse hadoop2.7.3 环境搭建
查看>>
Jacob模板替换生成word文件、word合并、word转pdf文件
查看>>
代理模式
查看>>