結果

問題 No.2391 SAN 値チェック
ユーザー gew1fw
提出日時 2025-06-12 15:13:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 81,336 KB
最終ジャッジ日時 2025-06-12 15:13:19
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

N = int(input())

max_fact = N
fact = [1] * (max_fact)
for i in range(1, max_fact):
    fact[i] = fact[i-1] * i % MOD

inv_fact = [1] * (max_fact)
if max_fact > 0:
    inv_fact[max_fact-1] = pow(fact[max_fact-1], MOD-2, MOD)
    for i in range(max_fact-2, -1, -1):
        inv_fact[i] = inv_fact[i+1] * (i+1) % MOD

ans = [0] * (N + 1)

for i in range(1, N + 1):
    k = N - i
    sign = pow(-1, k, MOD)
    term = sign * fact[N-1] % MOD
    inv_part = inv_fact[i-1] * pow(inv_fact[N - i], 2, MOD) % MOD
    ans[i] = term * inv_part % MOD

for a in ans:
    print(a)
0