competitive-cpp

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub fiore57/competitive-cpp

:warning: math/random-number.cpp

Back to top page

Code

class RandomNumber {
public:
    RandomNumber()
        : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
    int operator()(const int a, const int b) // [a, b)
    {
        uniform_int_distribution<int> dist(a, b - 1);
        return dist(mt);
    }
    int operator()(const int b) // [0, b)
    {
        return (*this)(0, b);
    }

private:
    mt19937 mt;
};

#line 1 "math/random-number.cpp"
class RandomNumber {
public:
    RandomNumber()
        : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
    int operator()(const int a, const int b) // [a, b)
    {
        uniform_int_distribution<int> dist(a, b - 1);
        return dist(mt);
    }
    int operator()(const int b) // [0, b)
    {
        return (*this)(0, b);
    }

private:
    mt19937 mt;
};

Back to top page