2025-03-09 23:28:43 +03:00
|
|
|
#include <array>
|
|
|
|
#include <bit>
|
|
|
|
#include <random>
|
|
|
|
#include <regex>
|
|
|
|
|
|
|
|
namespace s2ga
|
2025-03-08 20:37:26 +03:00
|
|
|
{
|
2025-03-09 23:28:43 +03:00
|
|
|
template<class... T>
|
|
|
|
struct always_false: std::false_type
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
class lehmer64
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
lehmer64(__uint128_t seed = 0)
|
|
|
|
{
|
|
|
|
this->seed(seed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void seed(__uint128_t z)
|
|
|
|
{
|
|
|
|
if(z == 0)
|
|
|
|
{
|
|
|
|
z = 0xC0FFEE;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t operator()() noexcept
|
|
|
|
{
|
|
|
|
s *= 0xda942042e4dd58b5;
|
|
|
|
return s >> 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr uint64_t min()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2025-03-08 20:37:26 +03:00
|
|
|
|
2025-03-09 23:28:43 +03:00
|
|
|
static constexpr uint64_t max()
|
|
|
|
{
|
|
|
|
return UINT64_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T random(T min, T max)
|
|
|
|
{
|
|
|
|
if constexpr(std::is_integral_v<T>)
|
|
|
|
{
|
|
|
|
return std::uniform_int_distribution<T>(min, max)(*this);
|
|
|
|
}
|
|
|
|
else if constexpr(std::is_floating_point_v<T>)
|
|
|
|
{
|
|
|
|
return std::uniform_real_distribution<T>(min, max)(*this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static_assert(always_false<T>::value,
|
|
|
|
"unsupported distribution type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
__uint128_t s;
|
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(std::uniform_random_bit_generator<lehmer64>);
|
|
|
|
}; // namespace s2ga
|
|
|
|
|
|
|
|
inline void foo()
|
|
|
|
{
|
2025-03-08 20:37:26 +03:00
|
|
|
}
|