我这样使用会不会导致产生的随机数不是伪随机而不均匀啊:
typedef long long ll;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll rd(ll l, ll r) {
uniform_int_distribution<ll> g(l, r);
return g(rnd);
}
int main() {
int a[100005];
for(int i = 1; i <= 100000000; i++) {
++a[rd(1, 100000)];
}
return 0;
}
就是每次都在函数里新建了一个 uniform_int_distribution<long long>,而不是一直使用同一个。
看了一下 a 数组,里面的数据在 90∼110 左右,感觉还是挺均匀的。