关于随机数的一些科技
大家都知道随机数要用mt19937,那么关于数列和区间来说有几种科技。
首先不要再使用random_shuffle()了,shuffle()可以用mt19937:
mt19937_64 rnd(time(0));
shuffle(s.begin(), s.end(), rnd);
至于生成随机数在一个区间里,可以使用随机数引擎:
mt19937_64 rnd(time(0));
uniform_int_distribution <u64> dist_rand(0, n - 1);
int s = dist_rand(rnd);
几个随机算法好题:
https://codeforces.com/gym/105386/problem/K
https://codeforces.com/contest/1305/problem/F
https://atcoder.jp/contests/abc272/tasks/abc272_g

浙公网安备 33010602011771号