結果

問題 No.2391 SAN 値チェック
ユーザー lam6er
提出日時 2025-04-16 00:41:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 79,368 KB
最終ジャッジ日時 2025-04-16 00:45:07
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

def main():
    import sys
    N = int(sys.stdin.readline())
    
    max_fact = N
    fact = [1] * (max_fact + 1)
    for i in range(1, max_fact + 1):
        fact[i] = fact[i-1] * i % MOD
    
    inv_fact = [1] * (max_fact + 1)
    inv_fact[max_fact] = pow(fact[max_fact], MOD-2, MOD)
    for i in range(max_fact-1, -1, -1):
        inv_fact[i] = inv_fact[i+1] * (i+1) % MOD
    
    for i in range(N+1):
        if i == 0:
            print(0)
            continue
        exponent = N - i
        sign = 1 if (exponent % 2 == 0) else -1
        a_i = sign * inv_fact[exponent]
        a_i %= MOD
        print(a_i)
        
if __name__ == "__main__":
    main()
0