結果

問題 No.58 イカサマなサイコロ
ユーザー tonnnura172tonnnura172
提出日時 2020-05-10 15:21:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 1,342 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 10,128 KB
最終ジャッジ日時 2023-09-22 02:11:02
合計ジャッジ時間 1,391 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,072 KB
testcase_01 AC 35 ms
9,912 KB
testcase_02 AC 32 ms
9,884 KB
testcase_03 AC 34 ms
10,032 KB
testcase_04 AC 33 ms
10,048 KB
testcase_05 AC 34 ms
10,128 KB
testcase_06 AC 34 ms
10,116 KB
testcase_07 AC 32 ms
9,884 KB
testcase_08 AC 33 ms
10,012 KB
testcase_09 AC 34 ms
10,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, log
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
import random
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
K = INT()

dp1 = [[0]*(6*N+1) for _ in range(N+1)]
dp2 = [[0]*(6*N+1) for _ in range(N+1)]
dp1[0][0] = 1
dp2[0][0] = 1

for i in range(1, N+1):
	for j in range(1, 6*i+1):
		for k in range(1, 7):
			if j-k >= 0:
				dp1[i][j] += dp1[i-1][j-k]/6

for i in range(1, N+1):
	for j in range(1, 6*i+1):
		if i <= K:
			for k in range(4, 7):
				if j-k >= 0:
					dp2[i][j] += dp2[i-1][j-k]/3
		else:
			for k in range(1, 7):
				if j-k >= 0:
					dp2[i][j] += dp2[i-1][j-k]/6

ans = 0
for i in range(1, 6*N+1):
	for j in range(i):
		ans += dp2[N][i]*dp1[N][j]
print(ans)
0