結果

問題 No.3145 Astral Parentheses Sequence
ユーザー titia
提出日時 2025-05-18 04:27:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 68,612 KB
最終ジャッジ日時 2025-05-18 04:27:16
合計ジャッジ時間 12,860 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,mod=map(int,input().split())

if N%3!=0:
    print(0)
    exit()

DP=[1,1]

for i in range(2,501):
    score=0
    SUM=i-1

    for x in range(SUM+1):
        for y in range(SUM+1-x):
            z=SUM-x-y
            score+=DP[x]*DP[y]%mod*DP[z]%mod
            score%=mod

    DP.append(score)

print(DP[N//3]%mod)
0