/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <chrono>
#include <random>
#include <thread>
#include <cstdint>
auto& get_random_gen_ref() {
thread_local static std::random_device rd;
thread_local static size_t thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id());
thread_local static long long time = std::chrono::high_resolution_clock::now().time_since_epoch().count();
thread_local static std::seed_seq seeds{
static_cast<uint_least32_t>(time>>32), static_cast<uint_least32_t>(time),
static_cast<uint_least32_t>(thread_id >> 32), static_cast<uint_least32_t>(thread_id),
rd(), rd(), rd(), rd(), rd(), rd(), rd()
};
thread_local static std::mt19937_64 mt{seeds};
return mt;
}
auto random_range = [](auto a, auto b){
return std::uniform_int_distribution<>{a,b}(get_random_gen_ref());
};
int main()
{
double wins = 0;
const int tries = 1000000;
for(int i=0; i<tries; ++i){
int a = 0, b=1;
while(b<3 && a<3){
if(random_range(1,100) > 70)
b++;
else
a++;
}
if(a==3)
wins++;
}
std::cout<<wins/tries;
return 0;
}