#include #include #include using namespace std; int bitcount(int a){ int r = 0; while(a){ r++; a -= a & -a; } return r; } int main(){ int n, k; cin >> n >> k; random_device rnd; mt19937 mt(rnd()); uniform_int_distribution<> rand16(1, 6), rand46(4, 6), randn((1 << k) - 1, (1 << n) - 1); auto start = chrono::system_clock::now(); int all = 0, win = 0; while(chrono::duration_cast(chrono::system_clock::now() - start).count() < 4990){ int puni = 0, muni = 0; int a = randn(mt); while(bitcount(a) != k) a = randn(mt); for(int i = 0; i < n; i++) puni += ((a >> i) & 1) ? rand46(mt) : rand16(mt); for(int i = 0; i < n; i++) muni += rand16(mt); all++; if(muni < puni) win++; } cout << 1. * win / all << endl; }