2017 Multi-University Training Contest
来源:互联网 发布:php字符串截取 编辑:程序博客网 时间:2024/06/06 12:22
题目链接:http://acm.hdu.edu.cn/contests/contest_show.php?cid=759
Add More Zero
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2245 Accepted Submission(s): 1053
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 between0 and (2m−1) (inclusive).
As a young man born with ten fingers, he loves the powers of10 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 integerm , your task is to determine maximum possible integer k that is suitable for the specific supercomputer.
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between
As a young man born with ten fingers, he loves the powers of
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
Input
The input contains multiple test cases. Each test case in one line contains only one positive integer m , satisfying 1≤m≤105 .
Output
For each test case, output "Case #x : y " in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
Sample Input
164
Sample Output
Case #1: 0Case #2: 19
解析:等式两边同时取模,转换下就可以了
代码:
#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N = 1000009;const int mod = 1e9+7ll;int main(){ int m, cnt = 0; while(~scanf("%d", &m)) { int ans = m * log10(2.0); printf("Case #%d: %d\n", ++cnt, ans); } return 0;}
Balala Power!
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4809 Accepted Submission(s): 387
Problem Description
Talented Mr.Tang has
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
Input
The input contains multiple test cases.
For each test case, the first line contains one positive integersn , the number of strings. (1≤n≤100000)
Each of the nextn lines contains a string si consisting of only lower case letters. (1≤|si|≤100000,∑|si|≤106)
For each test case, the first line contains one positive integers
Each of the next
Output
For each test case, output "Case #x : y " in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
Sample Input
1a2aabb3abaabc
Sample Output
Case #1: 25Case #2: 1323Case #3: 18221
解析:每个字符对答案的贡献都可以看作一个 26 进制的数字,问题相当于要给这些贡献加一个 0 到 25 的权重使得答案最大。最大的数匹配 25,次大的数匹配 24,依次类推。排序后这样依次贪心即可,唯一注意的是不能出现前导 0。
代码:
#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N = 1000009;const LL mod = 1e9+7ll;//typedef pair<int, char> P;int a[100100][33];char s[100100];int x[33], vis[33], m;bool cmp(int p, int q){ for(int j = m-1; j >= 0; j--) { if(a[j][p] < a[j][q]) return false; else if(a[j][p] > a[j][q]) return true; } return true;}void Sort(){ for(int i = 0; i < 26; i++) x[i] = i; for(int i = 0; i < 25; i++) { for(int j = i + 1; j < 26; j++) { if(cmp(x[i], x[j])) { int t = x[i]; x[i] = x[j]; x[j] = t; } } }}int main(){ int n, cnt = 0; while(~scanf("%d", &n)) { m = 0; memset(vis, 0, sizeof(vis)); memset(a, 0, sizeof(a)); for(int i = 1; i <= n; i++) { scanf(" %s", s); int len = strlen(s); m = max(m, len); int k = 0; vis[s[0]-'a'] = 1; for(int j = len - 1; j >= 0; j--){a[k][s[j] - 'a']++;k++;} } int t[33]; memset(t, 0, sizeof(t)); for(int i = 0; i < m-1; i++) { for(int j = 0; j < 26; j++) { int cur = (t[j] + a[i][j]); a[i][j] = cur % 26; t[j] = cur / 26; } } for(int i = 0; i < 26; i++) a[m-1][i] += t[i]; Sort(); LL ans = 0ll; int k = 1, p; for(int i = 0; i < 26; i++) { int j = x[i]; if(vis[j] == 0) { p = j; break; } } for(int i = 0; i < 26; i++) { int cur = x[i]; if(p == cur) continue; LL num = 0ll; for(int j = m - 1; j >= 0; j--) num = (num * 26 + k * a[j][cur]) % mod; ans = (ans + num) % mod; k++; } printf("Case #%d: %lld\n", ++cnt, ((ans%mod)+mod)%mod); } return 0;}
KazaQ's Socks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2375 Accepted Submission(s): 1074
Problem Description
KazaQ wears socks everyday.
At the beginning, he hasn pairs of socks numbered from 1 to n in his closets.
Every morning, he puts on a pair of socks which has the smallest number in the closets.
Every evening, he puts this pair of socks in the basket. If there aren−1 pairs of socks in the basket now, lazy KazaQ has to wash them. These socks will be put in the closets again in tomorrow evening.
KazaQ would like to know which pair of socks he should wear on thek -th day.
At the beginning, he has
Every morning, he puts on a pair of socks which has the smallest number in the closets.
Every evening, he puts this pair of socks in the basket. If there are
KazaQ would like to know which pair of socks he should wear on the
Input
The input consists of multiple test cases. (about 2000 )
For each case, there is a line contains two numbersn,k (2≤n≤109,1≤k≤1018) .
For each case, there is a line contains two numbers
Output
For each test case, output "Case #x : y " in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
Sample Input
3 73 64 9
Sample Output
Case #1: 3Case #2: 1Case #3: 2
解析:找下规律即可,比如n = 4, 123 412312 412312 412312 ,注意特判n=2
代码:
#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N = 1000009;const int mod = 1e9+7ll;LL solve(LL n, LL k){ if(n == 2&&k&1) return 1; else if(n == 2) return 2; if(k <= n - 1) return k; k -= n - 1; k %= 2*(n-1); if(k == 0) return n - 2; if(k <= n - 1) { if(k == 1) return n; return k - 1; } k -= n - 1; if(k == 1) return n-1; return k - 1;}int main(){ LL n, k; int cnt = 0; while(~scanf("%lld%lld", &n, &k)) { printf("Case #%d: ", ++cnt); cout << solve(n, k) << endl; } return 0;}
阅读全文
0 0
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- #2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- #2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- js代码中不加alert后边的代码不执行
- SQL基本语法---数据操作
- node 中文api doc
- 指针专项
- hadoop配置ha后,hbase配置的变化
- 2017 Multi-University Training Contest
- KahaDB简介
- JAVA 抛出java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符 异常
- 有()个2012位数,其任意两个邻数位依序依序构成的两位数均能被17或23整除。
- App主流框架UINavigationController && UITabBarController的简单使用
- wpf中textbox换行解决方法
- ligerTree的使用
- CC2640 SNV
- memcached 的安装以及简单使用