#include <iostream>
#include <map>
#include <random>

double get_die_probability(unsigned int age)
{
    const std::map<int, double> percents = {
        {0, 1.161756638},
        {1, 0.194279696},
        {5, 0.115889718},
        {10, 0.153797951},
        {15, 0.559759184},
        {20, 0.838678816},
        {25, 0.799340854},
        {30, 0.913264801},
        {35, 1.283487819},
        {40, 2.179927672},
        {45, 3.242747089},
        {50, 4.254341371},
        {55, 5.207398478},
        {60, 6.038474388},
        {65, 7.035735454},
        {70, 9.236823110},
        {75, 12.57703684},
        {80, 15.47280922},
        {85, 28.72402438}
    };
    auto it = percents.lower_bound(age);
    if (it == percents.end()) {
        return percents.rbegin()->second;
    }
    return it->second;
}

int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_real_distribution<double> distribution(0, 100.);

    unsigned int age = 0;
    for (;;) {
        auto percent = distribution(gen);
        if (percent <= get_die_probability(age)) {
            break;
        }
        ++age;
        std::cout << "It's your birthday! You turned: " << age << std::endl;
    }
    std::cout << "You die at " << age << std::endl;
    return 0;
}
