結果
問題 |
No.2391 SAN 値チェック
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:42:10 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,177 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,488 KB |
実行使用メモリ | 81,536 KB |
最終ジャッジ日時 | 2025-03-20 20:42:17 |
合計ジャッジ時間 | 2,657 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 14 |
ソースコード
MOD = 998244353 def main(): import sys N = int(sys.stdin.readline().strip()) max_n = N # Precompute factorial and inverse factorial fact = [1] * (max_n + 1) for i in range(1, max_n+1): fact[i] = fact[i-1] * i % MOD inv_fact = [1] * (max_n + 1) inv_fact[max_n] = pow(fact[max_n], MOD-2, MOD) for i in range(max_n-1, -1, -1): inv_fact[i] = inv_fact[i+1] * (i+1) % MOD results = [0] * (N + 1) if N == 0: print(1) return for i in range(0, N+1): if i == 0: results[i] = 0 continue k = N - i sign = 1 if k % 2 == 0 else -1 # Convert sign to MOD representation sign = 1 if sign == 1 else MOD - 1 if i-1 > N-1 or N-1 <0: C = 0 else: # C = C(N-1, i-1) C = fact[N-1] * inv_fact[i-1] % MOD C = C * inv_fact[(N-1) - (i-1)] % MOD term = C * inv_fact[k] % MOD term = term * sign % MOD results[i] = term for res in results: print(res) if __name__ == "__main__": main()