日本情報オリンピック 第5回本選 第3問 Reloaded
あともうちょっとなんだけど重くて動かない。12点。
module Main (main) where
import Control.Monad
import Data.List (nub, sortBy)
import System.Environment
ex = nub . map (sortBy (flip compare)) . f
f :: Int -> [[Int]]
f 1 = [[1]]
f x = [x]:concatMap (f' x) [1..(x-1)]
f' x y = map (++ [(x-y)]) $ f y
showResult :: [[Int]] -> String
showResult = concatMap (flip (++) "\n" . unwords . map show)
main = do
(inputFile:_) <- getArgs
n <- liftM (read . head . lines) $ readFile inputFile
writeFile "output.txt" $ showResult $ ex n