Skip to content

Instantly share code, notes, and snippets.

@HinataYukari
Created December 28, 2017 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HinataYukari/7541955aac8f4e56978c1d13a7a79faf to your computer and use it in GitHub Desktop.
Save HinataYukari/7541955aac8f4e56978c1d13a7a79faf to your computer and use it in GitHub Desktop.
import Control.Applicative
import Data.List
import Control.Monad
strToInt s = (read :: String -> Integer) s
main :: IO ()
main = do
-- 整数の入力
n <- readLn
-- kaigyousuuretu
ts <- sort <$> map strToInt <$> replicateM n getLine
-- 出力
let m = 1000000007 :: Integer
putStrLn . show . sum $ scanl' (+) 0 ts
putStrLn . show . (`mod` m) . product $ map ((\n -> foldl1' (*) [1..n]) . length') $ group ts
length' :: [Integer] -> Integer
length' xs = fromIntegral $ length xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment