以下程序按理说不可能死循环,但是却稳定在第 2049 次输出时死循环。求助……
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull rnd(){
ull ret=0,p=1;
for(int o=0;o<64;o++)ret+=rand()%2*p,p*=2;
return ret;
}
set<ull> mp;
int main() {
srand(time(0));
for(int i=1;i<=2049;i++){
ull w=rnd();
while(mp.count(w))w=rnd();
mp.insert(w);
printf("%llu %d\n",w,i);
}
return 0;
}