結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー june19312june19312
提出日時 2024-04-23 14:52:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 973 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 60,928 KB
最終ジャッジ日時 2024-04-23 14:52:51
合計ジャッジ時間 1,525 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,196 KB
testcase_01 AC 48 ms
58,368 KB
testcase_02 AC 41 ms
52,608 KB
testcase_03 AC 41 ms
52,608 KB
testcase_04 AC 49 ms
58,496 KB
testcase_05 AC 51 ms
60,928 KB
testcase_06 AC 46 ms
58,752 KB
testcase_07 AC 53 ms
60,672 KB
testcase_08 AC 41 ms
51,840 KB
testcase_09 AC 42 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P,C = map(int,input().split())

sosu = [2,3,5,7,11,13]
gose = [4,6,8,9,10,12]

dic1 = {}
if P > 0:
    dic1[1] = 1

for i in range(P):
    next = {}
    for ind,val in dic1.items():
        for j in sosu:
            if ind*j in next:
                next[ind*j] += val/6
            else:
                next[ind*j] = val/6
    dic1 = next.copy()

dic2 = {}
if C > 0:
    dic2[1] = 1

for i in range(C):
    next = {}
    for ind,val in dic2.items():
        for j in gose:
            if ind*j in next:
                next[ind*j] += val/6
            else:
                next[ind*j] = val/6
    dic2 = next.copy()

ans = 0

if len(dic1) and len(dic2):
    for ind,val in dic1.items():
        for ind2,val2 in dic2.items():
            ans += ind*ind2*val*val2
            
elif len(dic1) and not len(dic2):
    for ind,val in dic1.items():
        ans += ind*val

elif not len(dic1) and len(dic2):
    for ind,val in dic2.items():
        ans += ind*val

print(ans)
0