結果

問題 No.212 素数サイコロと合成数サイコロ (2)
コンテスト
ユーザー togatoga
提出日時 2015-09-03 19:43:32
言語 PyPy2
(7.3.20)
結果
AC  
実行時間 765 ms / 5,000 ms
コード長 612 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 141 ms
コンパイル使用メモリ 77,424 KB
最終ジャッジ日時 2025-12-03 16:34:52
ジャッジサーバーID
(参考情報)
judge2 / judge2
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

P,C = map(int,raw_input().split())
dice1 = [2, 3, 5, 7, 11, 13]
dice2 = [4, 6, 8, 9, 10, 12]

def dice(cnt1, cnt2):
    if (cnt1 == 0 and cnt2 == 0):
        return 1.0
    res = 0
    if (cnt1 > 0 and cnt2 > 0):
        for x in dice1:
            for y in dice2:
                res += (x * y) * (1 / 36.0) * dice(cnt1 - 1, cnt2 - 1)
    elif (cnt1 > 0):
        for x in dice1:
            res += x * (1 / 6.0) * dice(cnt1 - 1, cnt2)
    elif (cnt2 > 0):
        for x in dice2:
            res += x * (1 / 6.0) * dice(cnt1, cnt2 - 1)
    return res
            
print ("%.20lf" % (dice(P, C)))
        
    
0