Data structures 这段代码是如何生成随机数的?
我现在正在学习treap,我得到了一个实现,在这个实现中,这个家伙使用了一些奇怪的方法来生成随机数作为优先级。我无法获得它。有人介意解释一下它是如何工作的吗Data structures 这段代码是如何生成随机数的?,data-structures,treap,Data Structures,Treap,我现在正在学习treap,我得到了一个实现,在这个实现中,这个家伙使用了一些奇怪的方法来生成随机数作为优先级。我无法获得它。有人介意解释一下它是如何工作的吗 struct xor_128 { ull x,y,z,w; xor_128(): x(1234567892851659llu), y(3631515817918578190llu),z(711737163082llu), w(916951651388197517llu) {}
struct xor_128
{
ull x,y,z,w;
xor_128(): x(1234567892851659llu), y(3631515817918578190llu),z(711737163082llu), w(916951651388197517llu) {}
ull next()
{
ull t=x^(x<<11);// ull is unsigned long long he used
x=y;
y=z;
z=w;
return w=w^(w>>19)^t^(t>>8);
}
};
结构异或128
{
ull x,y,z,w;
xor_128():x(123456782851659LLU),y(3631515817918578190llu),z(711737163082llu),w(91695165138819517LLU){}
下一步()
{
ull t=x^(x19)^t^(t>>8);
}
};