結果

問題 No.75 回数の期待値の問題
ユーザー ytftytft
提出日時 2022-11-07 13:12:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 361 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 33,380 KB
最終ジャッジ日時 2023-09-28 02:42:42
合計ジャッジ時間 6,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
29,688 KB
testcase_01 AC 146 ms
29,924 KB
testcase_02 AC 133 ms
29,948 KB
testcase_03 AC 129 ms
29,904 KB
testcase_04 AC 130 ms
29,896 KB
testcase_05 AC 133 ms
29,848 KB
testcase_06 AC 132 ms
29,856 KB
testcase_07 AC 131 ms
29,908 KB
testcase_08 AC 132 ms
29,868 KB
testcase_09 AC 133 ms
31,496 KB
testcase_10 AC 134 ms
29,876 KB
testcase_11 AC 134 ms
29,912 KB
testcase_12 AC 133 ms
29,912 KB
testcase_13 AC 136 ms
31,468 KB
testcase_14 AC 133 ms
30,028 KB
testcase_15 AC 135 ms
29,940 KB
testcase_16 AC 137 ms
31,940 KB
testcase_17 AC 138 ms
30,924 KB
testcase_18 AC 144 ms
33,380 KB
testcase_19 AC 145 ms
31,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
input=lambda:sys.stdin.readline().rstrip()
#D,P=map(float,input().split())
K=int(input())
A=[[int(i==j) for i in range(K)] for j in range(K)]
b=[[1] for i in range(K)]
for i in range(K):
	for j in range(1,7):
		if i+j<K:
			A[i][i+j]-=1/6
		elif i+j>K:
			A[i][0]-=1/6
A=np.array(A)
b=np.array(b)
print((np.linalg.inv(A)@b)[0][0])
0