c++的rand()函数只能生成小于3e4(int16)的随机数,很多时候不够用
使用rand() * rand()实际上也不符合分布
update:以前的删了,都没初始化种子,以后就用这个吧。
#include<chrono>
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
用法: cout << rng() << endl;
c++的rand()函数只能生成小于3e4(int16)的随机数,很多时候不够用
使用rand() * rand()实际上也不符合分布
update:以前的删了,都没初始化种子,以后就用这个吧。
#include<chrono>
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
用法: cout << rng() << endl;