#include #include #include constexpr unsigned int EXP = 1000000; std::random_device rd; std::mt19937 mt(rd()); std::uniform_int_distribution dice(1, 6); std::uniform_int_distribution unfair_dice(4, 6); unsigned short experiment(unsigned short& n, unsigned short& k) { unsigned short taro_score = 0; unsigned short jiro_score = 0; for (unsigned short i = 0; i < n; i++) { jiro_score += dice(mt); if (i < k) { taro_score += unfair_dice(mt); } else { taro_score += dice(mt); } } if (taro_score > jiro_score) { return 1; } else { return 0; } } double compute_probability(unsigned short n, unsigned short k, unsigned int times) { unsigned int taro_wins = 0; for (unsigned int i = 0; i < times; i++) { taro_wins += experiment(n, k); } return (double)taro_wins / (double)times; } int main() { unsigned short n, k; std::cin >> n >> k; double answer = compute_probability(n, k, EXP); std::cout << std::fixed << std::setprecision(6) << answer << std::endl; return 0; }