結果

問題 No.2299 Antitypoglycemia
ユーザー qibqib
提出日時 2023-05-16 19:46:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 331 bytes
コンパイル時間 484 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 77,644 KB
最終ジャッジ日時 2023-08-21 08:26:06
合計ジャッジ時間 4,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,284 KB
testcase_01 AC 68 ms
70,968 KB
testcase_02 AC 73 ms
71,232 KB
testcase_03 AC 76 ms
76,864 KB
testcase_04 AC 76 ms
76,880 KB
testcase_05 AC 75 ms
76,372 KB
testcase_06 AC 75 ms
76,948 KB
testcase_07 AC 74 ms
76,112 KB
testcase_08 AC 73 ms
76,788 KB
testcase_09 AC 74 ms
77,264 KB
testcase_10 AC 75 ms
76,216 KB
testcase_11 AC 74 ms
76,460 KB
testcase_12 AC 75 ms
77,220 KB
testcase_13 AC 76 ms
77,304 KB
testcase_14 AC 72 ms
75,864 KB
testcase_15 AC 72 ms
75,836 KB
testcase_16 AC 74 ms
76,216 KB
testcase_17 AC 73 ms
76,160 KB
testcase_18 AC 77 ms
77,212 KB
testcase_19 AC 76 ms
77,464 KB
testcase_20 AC 74 ms
77,412 KB
testcase_21 AC 76 ms
77,456 KB
testcase_22 AC 78 ms
77,644 KB
testcase_23 AC 70 ms
71,352 KB
testcase_24 AC 71 ms
71,272 KB
testcase_25 AC 70 ms
70,976 KB
testcase_26 AC 70 ms
71,180 KB
testcase_27 AC 70 ms
70,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n, a, b = map(int, input().split())
if n == 2:
  if a == b:
    print("0")
  else:
    print("1")
  exit()

fact = [1 for _ in range(n + 1)]
for x in range(2, n + 1):
  fact[x] = (fact[x - 1] * x) % MOD

if a == b:
  print((n - 2) * fact[n - 1] % MOD)
else:
  print((fact[n] - 2 * fact[n - 1] + fact[n - 2]) % MOD)
0