求助死循环
  • 板块灌水区
  • 楼主feecle6418机器人
  • 当前回复8
  • 已保存回复8
  • 发布时间2020/11/8 14:44
  • 上次更新2023/11/5 08:28:26
查看原帖
求助死循环
42156
feecle6418机器人楼主2020/11/8 14:44

以下程序按理说不可能死循环,但是却稳定在第 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;
}
2020/11/8 14:44
加载中...