ll h(ll x) {
return x * x * x * 1237123 + 19260817;
}
ll f(ll x) {
ll cur = h(x & ((1 << 31) - 1)) + h(x >> 31);
return cur;
}
//更强的函数:(可用于整数哈希和树哈希)
ull splitmix64(ull x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}随机数相关:
#include<bits/stdc++.h>
using namespace std;
mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());//高精度时钟
//time_since_epoch() 返回从时钟纪元到当前时间点的duration对象
//count()是duration类的成员函数,返回时间间隔的计数值(以特定时间单位表示,纳秒)
int main(){
int a=1,b=10,c;
//std::chrono::duration_cast<std::chrono::milliseconds>(/*time*/);//转化时间为毫秒
//std::chrono::duration_cast<std::chrono::nanoseconds>(/*time*/);//转化时间为纳秒
//std::uniform_int_distribution<int> dist(min, max)均匀整数
//std::uniform_real_distribution<double>实数
//std::normal_distribution<double>正态分布
cout<<std::uniform_int_distribution<int>(a, b)(rnd);//均匀整数也可以这样写
}