結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー 👑 rin204rin204
提出日時 2022-01-20 08:02:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 317 ms / 5,000 ms
コード長 381 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 98,340 KB
最終ジャッジ日時 2024-05-02 20:13:51
合計ジャッジ時間 2,291 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
54,656 KB
testcase_01 AC 74 ms
67,456 KB
testcase_02 AC 54 ms
54,656 KB
testcase_03 AC 76 ms
64,896 KB
testcase_04 AC 150 ms
81,792 KB
testcase_05 AC 317 ms
98,340 KB
testcase_06 AC 204 ms
85,700 KB
testcase_07 AC 226 ms
91,388 KB
testcase_08 AC 80 ms
70,656 KB
testcase_09 AC 77 ms
68,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

p, c = map(int, input().split())

@lru_cache(None)
def dfs(i, x):
    if i == p + c:
        return x
        
    ret = 0
    if i < p:
        for a in [2, 3, 5, 7, 11, 13]:
            ret += dfs(i + 1, x * a / 6)
    else:
        for a in [4, 6, 8, 9, 10, 12]:
            ret += dfs(i + 1, x * a / 6)
    return ret
    
print(dfs(0, 1))
    
0