結果

問題 No.2529 Treasure Hunter
ユーザー ニックネームニックネーム
提出日時 2023-11-03 22:27:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 505 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 11,808 KB
実行使用メモリ 10,096 KB
最終ジャッジ日時 2023-11-03 22:27:42
合計ジャッジ時間 11,602 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
10,080 KB
testcase_01 AC 420 ms
10,096 KB
testcase_02 AC 419 ms
10,080 KB
testcase_03 AC 449 ms
10,080 KB
testcase_04 AC 436 ms
10,080 KB
testcase_05 AC 445 ms
10,080 KB
testcase_06 AC 431 ms
10,080 KB
testcase_07 AC 459 ms
10,080 KB
testcase_08 AC 451 ms
10,080 KB
testcase_09 AC 385 ms
10,080 KB
testcase_10 AC 441 ms
10,080 KB
testcase_11 AC 426 ms
10,080 KB
testcase_12 AC 498 ms
10,080 KB
testcase_13 AC 496 ms
10,080 KB
testcase_14 AC 496 ms
10,080 KB
testcase_15 AC 482 ms
10,080 KB
testcase_16 AC 490 ms
10,080 KB
testcase_17 AC 494 ms
10,080 KB
testcase_18 AC 490 ms
10,080 KB
testcase_19 AC 491 ms
10,080 KB
testcase_20 AC 505 ms
10,080 KB
testcase_21 AC 494 ms
10,080 KB
testcase_22 AC 501 ms
10,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n,m = map(int,input().split()); mod = 998244353
    dp0,dp1,dp2 = 1,n,(n>2)*(n*(n-1)//2-n)
    for _ in range(m-1):
        eq0 = (dp0+dp1+dp2)%mod
        eq1 = (n*dp0+(n-1)*dp1+(n-2)*dp2)%mod
        eq2 = ((n>2)*(n*(n-1)//2-n)*dp0+(n>2)*((n-1)*(n-2)//2-(n-2))*dp1+(n>3)*((n-2)*(n-3)//2-(n-4))*dp2)%mod
        dp0,dp1,dp2 = eq0,eq1,eq2
    print((dp0+dp1+dp2)%mod)
0