Add tags

Add tags to the following comment
また間違えた。orz orz
(正しい答えを出してたけど意図したコードではなかった)
今度こそ。

Windows XP
システムのプロパティ
  Pentium(R) 4 CPU 2.40GHz
  2.41 GHz, 0.99 GB RAM
ghc -O3 (GHC6.8.1)
ファイルにリダイレクトで5秒くらい。
1
2
3
4
5
6
7
8
main = putStr $ unlines $ map (unlines . map (bou!!))
  $ partitions 50 where
  bou = iterate ("[]"++) ""

partitions n = [1..n] >>= f n n  where
  f n p m
    | n <= m    = [replicate m 1]
    | otherwise = [x:xs| let p' = min (n-m+1) p, x <- [p',p'-1..(n+m-1)`div`m], xs <- f (n-x) x (m-1)]

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...