跳转至

C++ 语言相关

mt19937_64

可以快速生成 long long,常数和 rand() 差不多。

用法

声明:

#include<random>
#include<ctime>

std::mt19937_64 rng(clock());

使用:

long long x = rng();

nth_element 函数

\(O(n)\) 时间复杂度内,将数组的前 \(k\) 小移动到 \([begin, begin+k]\)
其中 \([begin, begin+k]\)\([begin+k+1,begin+n]\) 内部并不有序

用法

声明:

#include<algorithm>

使用:

nth_element(begin, begin+k, begin+n);

或从1开始:

nth_element(begin+1, begin+k, begin+1+n);