結果

問題 No.171 スワップ文字列(Med)
コンテスト
ユーザー くれちー
提出日時 2016-12-26 15:10:46
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 613 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,075 ms
コンパイル使用メモリ 194,944 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2026-05-25 15:06:52
合計ジャッジ時間 10,232 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

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