結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー togatogatogatoga
提出日時 2015-09-03 19:43:48
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 753 ms / 5,000 ms
コード長 612 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 77,380 KB
実行使用メモリ 79,624 KB
最終ジャッジ日時 2023-09-26 02:37:03
合計ジャッジ時間 3,186 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
76,376 KB
testcase_01 AC 94 ms
78,712 KB
testcase_02 AC 74 ms
76,724 KB
testcase_03 AC 85 ms
78,712 KB
testcase_04 AC 113 ms
78,868 KB
testcase_05 AC 753 ms
79,432 KB
testcase_06 AC 338 ms
79,476 KB
testcase_07 AC 333 ms
79,624 KB
testcase_08 AC 85 ms
78,680 KB
testcase_09 AC 86 ms
78,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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