// No.58 イカサマなサイコロ #include #include #include using namespace std; int main(void) { int N, K; cin >> N >> K; int M = 6 * N; vector dp1(M + 1), dp2(M + 1); dp1[0] = dp2[0] = 1; for (int i = 0; i < N; ++i) { for (int j = M; j >= 0; --j) { for (int k = 1; k <= 6; ++k) { if (j + k > M) continue; dp1[j + k] += dp1[j] / 6; } dp1[j] = 0; } } for (int i = 0; i < K; ++i) { for (int j = M; j >= 0; --j) { for (int k = 4; k <= 6; ++k) { if (j + k > M) continue; dp2[j + k] += dp2[j] / 3; } dp2[j] = 0; } } for (int i = K; i < N; ++i) { for (int j = M; j >= 0; --j) { for (int k = 1; k <= 6; ++k) { if (j + k > M) continue; dp2[j + k] += dp2[j] / 6; } dp2[j] = 0; } } double res = 0; for (int i = 0; i <= M; ++i) { for (int j = i + 1; j <= M; ++j) { res += dp1[i] * dp2[j]; } } cout << fixed << setprecision(10) << res << endl; }