This documentation is automatically generated by online-judge-tools/verification-helper
#include "random/xoshiro256starstar.hpp"
Source: https://prng.di.unimi.it/xoshiro256starstar.c
UniformRandomBitGenerator를 만족한다.
std::shuffle
, std::uniform_int_distribution
과 같은 C++ 표준 라이브러리 함수와 함께 사용할 수 있다.
#ifndef XOSHIRO256STARSTAR_HPP
#define XOSHIRO256STARSTAR_HPP
#include "splitmix64.hpp"
#include <array>
#include <cstdint>
#include <limits>
struct xoshiro256starstar {
public:
using result_type = std::uint64_t;
xoshiro256starstar(std::uint64_t seed = 0) {
splitmix64 g(seed);
for (auto &x : s) {
x = g();
}
}
std::uint64_t operator()() {
const std::uint64_t result = rotl(s[1] * 5, 7) * 9;
const std::uint64_t t = s[1] << 17;
s[2] ^= s[0];
s[3] ^= s[1];
s[1] ^= s[2];
s[0] ^= s[3];
s[2] ^= t;
s[3] = rotl(s[3], 45);
return result;
}
static constexpr std::uint64_t min() {
return std::numeric_limits<std::uint64_t>::min();
}
static constexpr std::uint64_t max() {
return std::numeric_limits<std::uint64_t>::max();
}
private:
static std::uint64_t rotl(const std::uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
std::array<std::uint64_t, 4> s;
};
#endif // XOSHIRO256STARSTAR_HPP
#line 1 "random/xoshiro256starstar.hpp"
#line 1 "random/splitmix64.hpp"
#include <cstdint>
#include <limits>
struct splitmix64 {
public:
using result_type = std::uint64_t;
splitmix64(std::uint64_t seed = 0) : x(seed) {}
std::uint64_t operator()() {
std::uint64_t z = (x += 0x9e3779b97f4a7c15);
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
return z ^ (z >> 31);
}
static constexpr std::uint64_t min() {
return std::numeric_limits<std::uint64_t>::min();
}
static constexpr std::uint64_t max() {
return std::numeric_limits<std::uint64_t>::max();
}
private:
std::uint64_t x; // The state can be seeded with any value.
};
#line 5 "random/xoshiro256starstar.hpp"
#include <array>
#line 8 "random/xoshiro256starstar.hpp"
struct xoshiro256starstar {
public:
using result_type = std::uint64_t;
xoshiro256starstar(std::uint64_t seed = 0) {
splitmix64 g(seed);
for (auto &x : s) {
x = g();
}
}
std::uint64_t operator()() {
const std::uint64_t result = rotl(s[1] * 5, 7) * 9;
const std::uint64_t t = s[1] << 17;
s[2] ^= s[0];
s[3] ^= s[1];
s[1] ^= s[2];
s[0] ^= s[3];
s[2] ^= t;
s[3] = rotl(s[3], 45);
return result;
}
static constexpr std::uint64_t min() {
return std::numeric_limits<std::uint64_t>::min();
}
static constexpr std::uint64_t max() {
return std::numeric_limits<std::uint64_t>::max();
}
private:
static std::uint64_t rotl(const std::uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
std::array<std::uint64_t, 4> s;
};