結果

問題 No.2299 Antitypoglycemia
ユーザー mtwtkmanmtwtkman
提出日時 2023-05-14 19:50:09
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 6,314 ms
コンパイル使用メモリ 164,948 KB
実行使用メモリ 7,392 KB
最終ジャッジ日時 2023-08-20 06:32:55
合計ジャッジ時間 6,864 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,084 KB
testcase_01 AC 3 ms
7,092 KB
testcase_02 AC 2 ms
7,392 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

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

solve :: Integer -> Integer -> Integer -> Integer
solve n a b =
  ( if a == b
      then fac (n - 1)
      else fac n - (fac (n - 1) * 2) + fac (n - 2)
  )
    `mod` 998244353

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