关于FHQ-Treap的随机种子

P4008 [NOI2003] 文本编辑器

@[__zzy__](/user/478552) `std::randon_device`
by Ruiqun2009 @ 2022-07-17 17:26:58


@[Ruiqun2009](/user/589895) 所以您可以再具体说一下要怎么用这个东西吗?
by __zzy__ @ 2022-07-17 17:29:15


@[__zzy__](/user/478552) ```cpp #include<random> #include<cstdio> static random_device rd; int main() { for (int i = 0; i < 1000; i++) printf("%u\n", rd()); } } ```
by Ruiqun2009 @ 2022-07-17 17:33:18


@[Ruiqun2009](/user/589895) 好的,谢谢您
by __zzy__ @ 2022-07-17 17:33:52


@[__zzy__](/user/478552) ``` srand((time(0)%(1<<20))|114514) ```
by 听取MLE声一片 @ 2022-07-17 17:45:52


@[听取MLE声一片](/user/253738) 这种臭种子我也试过,就是像什么 ``` srand(time(0)^114+514&1919-810); ```
by __zzy__ @ 2022-07-17 17:47:03


@[__zzy__](/user/478552) 效果应该都是类似的吧,我认为和种子无关
by 听取MLE声一片 @ 2022-07-17 17:47:47


@[听取MLE声一片](/user/253738) 说的对,fhq-treap本来就常数巨大(但是码量只有1.8k就很好
by __zzy__ @ 2022-07-17 17:48:55


`std::chrono::steady_clock::now().time_since_epoch().count()`
by 一之濑帆波 @ 2022-07-17 18:15:26


@[__zzy__](/user/478552) 对了,`random_device`不能直接使用,因为如果没记错的话,在计算机的某个硬件耗尽后,使用`random_device`程序效率会大大下降,而`random_device`使用这个硬件。所以还要搭配`linear_congruential_engine`、`mersenne_twister_engine`~~(不建议手动设参数)~~ 和`subtract_with_carry_engine`。 --- 如果要形成均匀/正态/二项式……分布,使用`uniform_int_distribution`/`uniform_real_distribution`,`normal_distribution`,`binomial_distribution`等等。 此外,`<random>`还有多个`typedef`,分别为: ```cpp typedef std::linear_congruential_engine<std::uint_fast32_t, 16807, 0, 2147483647> minstd_rand0; typedef std::linear_congruential_engine<std::uint_fast32_t, 48271, 0, 2147483647> minstd_rand; typedef std::mersenne_twister_engine<std::uint_fast32_t, 32, 624, 397, 31, 0x9908b0df, 11, 0xffffffff, 7, 0x9d2c5680, 15, 0xefc60000, 18, 1812433253> mt19937; typedef std::mersenne_twister_engine<std::uint_fast64_t, 64, 312, 156, 31, 0xb5026f5aa96619e9, 29, 0x5555555555555555, 17, 0x71d67fffeda60000, 37, 0xfff7eee000000000, 43, 6364136223846793005> mt19937_64; typedef std::subtract_with_carry_engine<std::uint_fast32_t, 24, 10, 24> ranlux24_base; typedef std::subtract_with_carry_engine<std::uint_fast64_t, 48, 5, 12> ranlux48_base; typedef std::discard_block_engine<std::ranlux24_base, 223, 23> ranlux24; typedef std::discard_block_engine<std::ranlux48_base, 389, 11> ranlux48; typedef std::shuffle_order_engine<std::minstd_rand0, 256> knuth_b; ```
by Ruiqun2009 @ 2022-07-18 14:53:36


| 下一页