弱校也不打多校,自己也可以咸鱼嘛。水一水,玩一玩
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 (2m−1) (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 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
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
![](http://acm.hdu.edu.cn/data/images/C642-1002-1.jpg)
Input
The input contains multiple test cases. 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)
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
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;}