結果

問題 No.2668 Trees on Graph Paper
ユーザー ニックネームニックネーム
提出日時 2024-03-08 23:32:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 385 ms / 3,000 ms
コード長 265 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 74,920 KB
最終ジャッジ日時 2024-03-08 23:32:53
合計ジャッジ時間 6,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,332 KB
testcase_01 AC 38 ms
53,332 KB
testcase_02 AC 38 ms
53,332 KB
testcase_03 AC 80 ms
74,920 KB
testcase_04 AC 38 ms
53,332 KB
testcase_05 AC 42 ms
53,332 KB
testcase_06 AC 37 ms
53,332 KB
testcase_07 AC 38 ms
53,332 KB
testcase_08 AC 44 ms
53,332 KB
testcase_09 AC 39 ms
53,332 KB
testcase_10 AC 38 ms
53,332 KB
testcase_11 AC 38 ms
53,332 KB
testcase_12 AC 38 ms
53,332 KB
testcase_13 AC 38 ms
53,332 KB
testcase_14 AC 238 ms
74,920 KB
testcase_15 AC 335 ms
74,920 KB
testcase_16 AC 195 ms
74,920 KB
testcase_17 AC 67 ms
74,920 KB
testcase_18 AC 351 ms
74,920 KB
testcase_19 AC 282 ms
74,920 KB
testcase_20 AC 301 ms
74,920 KB
testcase_21 AC 302 ms
74,920 KB
testcase_22 AC 297 ms
74,920 KB
testcase_23 AC 207 ms
74,920 KB
testcase_24 AC 361 ms
74,920 KB
testcase_25 AC 385 ms
74,920 KB
testcase_26 AC 361 ms
74,920 KB
testcase_27 AC 360 ms
74,920 KB
testcase_28 AC 38 ms
53,332 KB
testcase_29 AC 38 ms
53,332 KB
testcase_30 AC 38 ms
53,332 KB
testcase_31 AC 38 ms
53,332 KB
testcase_32 AC 40 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
x = 1; dp = [0]*3+[1]
for i in range(1,2*n): x = x*i%m
for i in range(1,2*n-2):
    dp = [(dp[0]+dp[2])%m,(dp[0]*i+dp[2]*i)%m,(dp[1]+dp[2]+dp[3])%m,(dp[1]*i+dp[2]*i+dp[3])%m]
    if i%2==0: x = x*(dp[0]+dp[1]+dp[2]*2+dp[3])%m
print(x)
0