AP
combinations x | x < 1 = 0
| x == 1 = 1
| otherwise = combinations (x-1) + combinations (x-2) + combinations (x-3)
Size: a a a
AP
combinations x | x < 1 = 0
| x == 1 = 1
| otherwise = combinations (x-1) + combinations (x-2) + combinations (x-3)
A
A
AP
combinations x | x < 1 = 0
| x == 1 = 1
| otherwise = combinations (x-1) + combinations (x-2) + combinations (x-3)
AP
JS
AP
к
A
TZ
TZ
AP
A
AP
[1, 1, 1, 1, 1]
[1, 2, 2]
[ 2, 1, 1, 1]
[ 2, 3]
...
(такие разницы получаются, если выкинуть один или два элемента с вкладом +1)AP
product . map ((variants !!) . length) . filter ((== 1) . head) . group
AP
:)
)TZ
TZ
AP
A
$ time ./10 < input10
2376
129586085429248
real 0m0.002s
user 0m0.001s
sys 0m0.001s