結果
| 問題 |
No.2391 SAN 値チェック
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 12:52:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,013 bytes |
| コンパイル時間 | 182 ms |
| コンパイル使用メモリ | 82,084 KB |
| 実行使用メモリ | 81,476 KB |
| 最終ジャッジ日時 | 2025-05-14 12:53:50 |
| 合計ジャッジ時間 | 2,143 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 14 |
ソースコード
MOD = 998244353
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
max_n = N
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)
for i in range(N + 1):
if i == 0:
results[i] = 0
else:
k = N - i
sign = 1 if k % 2 == 0 else MOD - 1
# Compute C(N-1, i-1) = fact[N-1] * inv_fact[i-1] * inv_fact[N-i] % MOD
comb = fact[N-1] * inv_fact[i-1] % MOD
comb = comb * inv_fact[N - i] % MOD
denominator_inv = inv_fact[k]
res = sign * comb % MOD
res = res * denominator_inv % MOD
results[i] = res
for res in results:
print(res)
if __name__ == "__main__":
main()
qwewe