結果

問題 No.171 スワップ文字列(Med)
ユーザー くれちーくれちー
提出日時 2016-12-26 15:10:46
言語 Haskell
(9.6.2)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 613 bytes
コンパイル時間 6,606 ms
コンパイル使用メモリ 164,116 KB
実行使用メモリ 8,092 KB
最終ジャッジ日時 2023-08-21 12:33:43
合計ジャッジ時間 7,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,760 KB
testcase_01 AC 3 ms
6,636 KB
testcase_02 AC 4 ms
7,344 KB
testcase_03 AC 3 ms
6,920 KB
testcase_04 AC 3 ms
6,888 KB
testcase_05 AC 3 ms
7,208 KB
testcase_06 AC 3 ms
7,452 KB
testcase_07 AC 3 ms
8,092 KB
testcase_08 AC 3 ms
7,940 KB
testcase_09 AC 3 ms
7,824 KB
testcase_10 AC 3 ms
6,756 KB
testcase_11 AC 3 ms
6,700 KB
testcase_12 AC 2 ms
6,832 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 #

countChar :: Char -> [Char] -> Integer
countChar c l = fromIntegral (length (filter (== c) l))

countChars' :: [Char] -> Char -> [Integer] -> [Integer]
countChars' l1 'Z' l2 = (countChar 'Z' l1) : l2
countChars' l1 c l2 = (countChar c l1) : countChars' l1 (succ c) l2 ++ l2

countChars :: [Char] -> [Integer]
countChars l = countChars' l 'A' []

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

solve :: [Char] -> Integer
solve s = (fact (sum l) `div` product (map fact l) - 1) `mod` 573 where
    l = countChars s

main :: IO ()
main = do
    s <- getLine
    putStrLn $ show (solve s)
0