結果
問題 |
No.2529 Treasure Hunter
|
ユーザー |
|
提出日時 | 2023-11-04 12:09:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 76,396 KB |
最終ジャッジ日時 | 2024-09-25 21:58:57 |
合計ジャッジ時間 | 3,356 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 |
ソースコード
mod = 998244353 def solve(): n,m = map(int,input().split()) dp = [1,0,0] for i in range(m): ndp = [0]*3 for bi in range(3): rest = n-bi if rest < 0: continue ndp[0] += dp[bi] ndp[0] %= mod if rest == 0: continue ndp[1] += dp[bi] * rest ndp[1] %= mod if rest == 1 or n < 4: continue ndp[2] += (rest*(rest-1)//2 - (n-2*bi)) * dp[bi] ndp[2] %= mod dp = ndp return sum(dp)%mod t = int(input()) for _ in range(t): print(solve())