#include <iostream>
#include <random>
#include <cstdint>
#include <tuple>
#include <algorithm>
// 計算機以外の実行を禁ずる。
std::size_t DoOne(std::size_t N, std::size_t C) {
std::size_t V = 0;
std::size_t Re = N;
std::size_t T = 0;
std::random_device rd;
std::mt19937 mt(rd());
//std::mt19937 mt;
std::uniform_int_distribution<std::size_t> UI(1, 10);
do {
N = Re;
Re = 0;
T = 0;
for (std::size_t i = 0; i < N; i++) {
std::size_t V = UI(mt);
T = std::max(T,V);
if (V >= C) { Re++; }
}
V += T;
}while(Re != 0);
return V;
}
int main() {
std::uintmax_t V = 0;
std::size_t DiceCount = 10;
std::size_t NumberLimit = 5;
std::size_t L = 1200000;
std::size_t Min = 11*DiceCount;
std::size_t Max = 0;
for (std::size_t i = 0; i < L; i++) {
std::size_t T = DoOne(DiceCount, NumberLimit);
V += T;
Min = std::min(Min, T);
Max = std::max(Max, T);
}
std::cout << "Do " << L << " count." << std::endl;
std::cout << "Min:" << Min << ',' << "Max:" << Max << std::endl;
std::cout << "Average:" << V / (double)L << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmFuZG9tPgojaW5jbHVkZSA8Y3N0ZGludD4KI2luY2x1ZGUgPHR1cGxlPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKCi8vCeioiOeul+apn+S7peWkluOBruWun+ihjOOCkuemgeOBmuOCi+OAggpzdGQ6OnNpemVfdCBEb09uZShzdGQ6OnNpemVfdCBOLCBzdGQ6OnNpemVfdCBDKSB7CglzdGQ6OnNpemVfdCBWID0gMDsKCXN0ZDo6c2l6ZV90IFJlID0gTjsKCXN0ZDo6c2l6ZV90IFQgPSAwOwoKCXN0ZDo6cmFuZG9tX2RldmljZSByZDsKCXN0ZDo6bXQxOTkzNyBtdChyZCgpKTsKCS8vc3RkOjptdDE5OTM3IG10OwoJc3RkOjp1bmlmb3JtX2ludF9kaXN0cmlidXRpb248c3RkOjpzaXplX3Q+IFVJKDEsIDEwKTsKCWRv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