码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj3098 Hash Killer II

时间:2017-04-29 18:49:13      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:turn   static   com   register   main   log   isp   c99   algorithm   

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

 

bzoj3098 Hash Killer II

标签:turn   static   com   register   main   log   isp   c99   algorithm   

原文地址:http://www.cnblogs.com/galaxies/p/bzoj3098.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!