當你第一眼看到這玩意兒的時候c++
確定禁不住吐槽:納尼?這是什麼鬼?算法
確實,這個東西不爲人知,可是它卻有着卓越的性能windows
mt19937是c++11中加入的新特性dom
它是一種隨機數算法,用法與rand()函數相似函數
可是具備速度快,週期長的特色(它的名字便來自週期長度:2^19937-1)性能
說的直白一點,咱們都知道rand()在windows下生成的數據範圍爲0-32767spa
可是這個函數的隨機範圍大概在\((-maxint,+maxint)\)(maxint爲int類型最大值)c++11
這個東西用法很是簡單code
#include<random> #include<ctime> std::mt19937 rnd(time(0)); int main() { printf("%lld\n",rnd()); return 0; }