結果

問題 No.170 スワップ文字列(Easy)
ユーザー okadukiokaduki
提出日時 2015-03-22 23:40:00
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 572 bytes
コンパイル時間 3,513 ms
コンパイル使用メモリ 143,192 KB
最終ジャッジ日時 2023-10-21 04:21:33
合計ジャッジ時間 4,150 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:3:1: error:
    Could not load module ‘Data.ByteString.Char8’
    It is a member of the hidden package ‘bytestring-0.11.4.0’.
    You can run ‘:set -package bytestring’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import qualified Data.ByteString.Char8 as B
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Data.List
import Debug.Trace

-- or readInteger
readInts :: B.ByteString -> [Int]
readInts = map (fst . fromJust . B.readInt) . B.words

getInts :: IO [Int]
getInts = liftM readInts B.getLine

f n [] = 1
f n (x:xs) = c n x * f (n-x) xs
  where c n m = product [1..n] `div` product [1..m] `div` product [1..(n-m)]
g :: String -> [Int]
g = map length . group . sort

main = do
  s <- getLine
  print $ (f (length s) $ g s) - 1
0