#include <iostream>
#include <vector>
#include <map>
#include <random>
int main()
{
// no hardware access on ideone
// std::random_device rd;
// std::mt19937 gen(rd());
std::mt19937 gen(time(NULL));
std::vector<double> p = {0, 1.0/15, 2.0/15, 3.0/15, 4.0/15, 5.0/15};
std::discrete_distribution<> d(p.begin(), p.end());
std::map<int, int> m;
for(int n=0; n<10000; ++n) {
++m[d(gen)];
}
for(auto i = m.begin(); i!=m.end(); ++i) {
std::cout << i->first << " generated " << i->second << " times\n";
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8cmFuZG9tPgogCmludCBtYWluKCkKewovLyBubyBoYXJkd2FyZSBhY2Nlc3Mgb24gaWRlb25lCi8vICAgIHN0ZDo6cmFuZG9tX2RldmljZSByZDsKLy8gICAgc3RkOjptdDE5OTM3IGdlbihyZCgpKTsKICAgIHN0ZDo6bXQxOTkzNyBnZW4odGltZShOVUxMKSk7CgogICAgc3RkOjp2ZWN0b3I8ZG91YmxlPiBwID0gezAsIDEuMC8xNSwgMi4wLzE1LCAzLjAvMTUsIDQuMC8xNSwgNS4wLzE1fTsKICAgIHN0ZDo6ZGlzY3JldGVfZGlzdHJpYnV0aW9uPD4gZChwLmJlZ2luKCksIHAuZW5kKCkpOwogICAgc3RkOjptYXA8aW50LCBpbnQ+IG07CiAgICBmb3IoaW50IG49MDsgbjwxMDAwMDsgKytuKSB7CiAgICAgICAgKyttW2QoZ2VuKV07CiAgICB9CiAgICBmb3IoYXV0byBpID0gbS5iZWdpbigpOyBpIT1tLmVuZCgpOyArK2kpIHsKICAgICAgICBzdGQ6OmNvdXQgPDwgaS0+Zmlyc3QgPDwgIiBnZW5lcmF0ZWQgIiA8PCBpLT5zZWNvbmQgPDwgIiB0aW1lc1xuIjsKICAgIH0KfQo=