bzoj3098 Hash Killer II

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3098

【题解】

生日问题:如果在[1,n]中选数,那么平均根号n次就能选到重复的。

那么直接随机即可。

注意l不能太小也不能太大,取20左右即可。

# include <stdio.h>
# include <string.h>
# include <algorithm>
// # include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int M = 5e5 + 10;
const int mod = 1e9+7;

# define RG register
# define ST static

int n = 100000, l = 20;

int main() {
    printf("%d %d\n", n, l);
    for (int i=1; i<=n; ++i) 
        printf("%c", (char)(rand()%26+'a'));
    return 0;
}
View Code

 

posted @ 2017-04-29 17:19  Galaxies  阅读(174)  评论(0编辑  收藏  举报