bzoj3098 Hash Killer II

mac2022-06-30  23

传送门: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

 

转载于:https://www.cnblogs.com/galaxies/p/bzoj3098.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)