結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー togatogatogatoga
提出日時 2015-09-03 19:43:32
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 612 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 6,656 KB
実行使用メモリ 10,388 KB
最終ジャッジ日時 2023-09-26 02:36:50
合計ジャッジ時間 7,535 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
5,924 KB
testcase_01 AC 14 ms
5,860 KB
testcase_02 AC 11 ms
5,776 KB
testcase_03 AC 15 ms
5,928 KB
testcase_04 AC 510 ms
5,852 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

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