結果
問題 | No.58 イカサマなサイコロ |
ユーザー |
![]() |
提出日時 | 2019-09-19 12:32:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 1,560 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-18 19:32:29 |
合計ジャッジ時間 | 971 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
totalDice = int(input()) ikasamaDice = int(input()) dic = [None for i in range(10)] def getPattern(index): if index >= totalDice - 1: return dict([(i + 1, 1) for i in range(6)]) if dic[index] is not None: return dic[index] ans = {} ret = getPattern(index + 1) for i, j in ret.items(): for k in [l + 1 for l in range(6)]: key = i + k if key in ans.keys(): ans[key] += j else: ans[key] = j dic[index] = ans return ans ikasamaDic = [None for i in range(10)] def getIkasamaPattern(index): if index >= ikasamaDice: return getPattern(index) if index >= totalDice - 1: return dict([(i + 4, 2) for i in range(3)]) if ikasamaDic[index] is not None: return dic[index] ans = {} ret = getIkasamaPattern(index + 1) for i, j in ret.items(): for k in [(l % 3) + 4 for l in range(6)]: key = i + k if key in ans.keys(): ans[key] += j else: ans[key] = j ikasamaDic[index] = ans return ans win = 0 lose = 0 draw = 0 pattern = getPattern(0) ikasama = getIkasamaPattern(0) for i in pattern.keys(): wCount = sum([v for j, v in ikasama.items() if j < i]) lCount = sum([v for j, v in ikasama.items() if j > i]) dCount = sum([v for j, v in ikasama.items() if j == i]) win += wCount * pattern[i] lose += lCount * pattern[i] draw += dCount * pattern[i] ans = lose / (win + lose + draw) print(ans)