学到了一个比 rand()
更随的随机数:
随机整数:
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r)
{
assert(r>=l);
return uniform_int_distribution<>(l,r)(rng);
}
实数:
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double rnd(double l, double r)
{
assert(r>=l);
return uniform_real_distribution<>(l,r)(rng);
}
标签:mt19937,int,double,since,rng,生成,随机数
From: https://www.cnblogs.com/copper-carbonate/p/16886600.html