#include <iostream>
#include <random>
#include <tuple>
#include <vector>
enum class Ball : unsigned char
{
GOLD,
SILVER,
};
int main()
{
const std::vector<std::tuple<Ball, Ball>> boxes = {
{ Ball::GOLD, Ball::GOLD },
{ Ball::GOLD, Ball::SILVER },
{ Ball::SILVER, Ball::SILVER },
};
const long inters = 100'000'000;
long both = 0;
long attempt = 0;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dist(0,
static_cast<int>(boxes.size()) - 1);
std::uniform_int_distribution<int> dist2(0, 1);
for (long i = 0; i < inters; i++)
{
const auto r = dist(gen);
const auto [b1, b2] = boxes[r];
const auto first = dist2(gen);
const auto u1 = first ? b1 : b2;
const auto u2 = !first ? b1 : b2;
if (u1 == Ball::GOLD)
{
attempt++;
if (u2 == Ball::GOLD)
both++;
}
}
std::cout << ((static_cast<double>(both) / attempt) * 100) << "%\n";
return 0;
}