結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-05 15:13:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 5,000 ms |
| コード長 | 771 bytes |
| コンパイル時間 | 244 ms |
| コンパイル使用メモリ | 81,772 KB |
| 実行使用メモリ | 60,032 KB |
| 最終ジャッジ日時 | 2024-07-19 08:20:37 |
| 合計ジャッジ時間 | 1,217 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
N = int(input())
K = int(input())
M = 6 * N # 出しうる最大の値
edited = [4,4,5,5,6,6]
normal = [1,2,3,4,5,6]
def f(X):
x = [0] * (M + 1)
x[0] = 1
dice = normal
for i in range(N):
new_x = [0] * (M + 1)
for j in range(M + 1):
if x[j] == 0:
continue
if i >= (N - K): # normalを(N - K)回以上使っていたら、Xに切り替える
dice = X
# print("dice",dice,"を振る")
for k in range(6):
# print(j + dice[k],"に",x[j] / 6,"の確率で到達")
new_x[j + dice[k]] += x[j] / 6
# print("new_x",new_x)
x = new_x
return x
jiro = f(normal)
taro = f(edited)
ans = 0
jiro_lose = 0
for i in range(len(taro)):
ans += taro[i] * jiro_lose
jiro_lose += jiro[i]
print(ans)