結果

問題 No.2299 Antitypoglycemia
ユーザー mtwtkmanmtwtkman
提出日時 2023-05-14 21:00:42
言語 Haskell
(9.8.2)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 1,463 ms
コンパイル使用メモリ 165,696 KB
実行使用メモリ 18,808 KB
最終ジャッジ日時 2023-08-20 07:09:49
合計ジャッジ時間 3,706 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,116 KB
testcase_01 AC 3 ms
7,100 KB
testcase_02 AC 3 ms
7,104 KB
testcase_03 AC 42 ms
16,736 KB
testcase_04 AC 43 ms
16,820 KB
testcase_05 AC 22 ms
14,308 KB
testcase_06 AC 42 ms
16,792 KB
testcase_07 AC 12 ms
12,612 KB
testcase_08 AC 42 ms
15,880 KB
testcase_09 AC 42 ms
16,324 KB
testcase_10 AC 23 ms
13,112 KB
testcase_11 AC 22 ms
13,528 KB
testcase_12 AC 43 ms
16,664 KB
testcase_13 AC 63 ms
17,364 KB
testcase_14 AC 8 ms
10,304 KB
testcase_15 AC 7 ms
9,976 KB
testcase_16 AC 23 ms
14,116 KB
testcase_17 AC 23 ms
13,272 KB
testcase_18 AC 42 ms
18,348 KB
testcase_19 AC 43 ms
18,384 KB
testcase_20 AC 63 ms
18,740 KB
testcase_21 AC 63 ms
18,808 KB
testcase_22 AC 42 ms
18,496 KB
testcase_23 AC 2 ms
7,080 KB
testcase_24 AC 2 ms
7,068 KB
testcase_25 AC 3 ms
7,020 KB
testcase_26 AC 2 ms
7,068 KB
testcase_27 AC 2 ms
7,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

split :: String -> [String]
split = go ("", [])
  where
    go :: (String, [String]) -> String -> [String]
    go (a, acc) "" = acc <> [a]
    go (a, acc) (' ' : xs) = go ("", acc <> [a]) xs
    go (a, acc) (x : xs) = go (a <> [x], acc) xs

prompt :: IO [String]
prompt = do split <$> getLine

m = 998244353

fac :: Integer -> Integer
fac 0 = 1
fac n = (fac (n - 1) * n) `mod` m

solve :: Integer -> Integer -> Integer -> Integer
solve n a b =
  let r = (fac n + ((m - 2) * fac (n - 1)) `mod` m) `mod` m
   in if a /= b then (r + fac (n - 2)) `mod` m else r

main :: IO ()
main = do
  vs <- prompt
  let [n, a, b] = map read [head vs, vs !! 1, vs !! 2]
  print $ solve n a b
0