結果
| 問題 | No.171 スワップ文字列(Med) | 
| コンテスト | |
| ユーザー |  くれちー | 
| 提出日時 | 2016-12-26 15:10:46 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 1,000 ms | 
| コード長 | 613 bytes | 
| コンパイル時間 | 11,842 ms | 
| コンパイル使用メモリ | 173,312 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-14 23:51:20 | 
| 合計ジャッジ時間 | 13,079 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
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)
            
            
            
        