結果

問題 No.171 スワップ文字列(Med)
コンテスト
ユーザー okaduki
提出日時 2015-03-22 23:45:54
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 593 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,127 ms
コンパイル使用メモリ 193,536 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2026-03-18 08:09:35
合計ジャッジ時間 1,486 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_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

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 = map toInteger . map length . group . sort

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