結果

問題 No.2299 Antitypoglycemia
ユーザー イルカ
提出日時 2024-06-11 00:22:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 62,740 KB
最終ジャッジ日時 2025-01-03 02:46:42
合計ジャッジ時間 2,548 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

# A≠Bのとき
# 先頭がBのパターン: (N-1)!通り
# 先頭がA,B以外のパターン: (N-2)*(N-2)*(N-2)!
# 足して整理すると(N-1)!+(N-2)*(N-2)*(N-2)!=(N-1)*(N-2)!+(N-2)*(N-2)*(N-2)!=(N^2-3N+3)*(N-2)!
# A=Bのとき
# (N-1)*(N-2)*(N-2)!
N, A, B = map(int, input().split())
MOD = 998244353
cnt = 1
if A!=B:
    components = [N**2-3*N+3] + list(range(1, N-1))
else:
    components = [N-1, N-2] + list(range(1, N-1))
for c in components:
    cnt = (cnt * c) % MOD
print(cnt)
"🐬"
0