传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3098
hint说的有道理。
如果你从n个数里随机选数,那么大约选根号n次就能选到一样的(当然选了n次还没碰上是因为RP太好了- -)。
这是著名的“生日攻击”问题,详情请看这里。
代码很短:
PS:貌似加了srand(time(NULL))会RE......
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
printf("%d %d\n",100000,20);
for(int i=1;i<=100000;++i)printf("%c",rand()%26+'a');
printf("\n");
return 0;
}