結果
| 問題 | No.2299 Antitypoglycemia |
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2023-05-12 21:58:03 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 712 bytes |
| 記録 | |
| コンパイル時間 | 190 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 59,008 KB |
| 最終ジャッジ日時 | 2026-05-22 17:31:51 |
| 合計ジャッジ時間 | 2,334 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
# 包除原理だな
mod = 998244353
N, A, B = map(int, input().split())
if A != B:
total = 1
for i in range(1, N+1):
total *= i
total %= mod
deduct1 = 1
for i in range(1, N):
deduct1 *= i
deduct1 %= mod
add1 = 1
for i in range(1, N-1):
add1 *= i
add1 %= mod
ans = (total - deduct1*2 + add1)%mod
#print(total, deduct1, add1)
print(ans)
elif A == B:
total = 1
for i in range(1, N+1):
total *= i
total %= mod
deduct1 = 1
for i in range(1, N):
deduct1 *= i
deduct1 %= mod
add1 = 0
ans = (total - deduct1*2 + add1)%mod
#print(total, deduct1, add1)
print(ans)
FromBooska