結果

問題 No.118 門松列(2)
ユーザー aimyaimy
提出日時 2017-04-21 16:35:43
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 411 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 162,456 KB
実行使用メモリ 77,168 KB
最終ジャッジ日時 2023-09-27 10:54:59
合計ジャッジ時間 7,175 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 404 ms
74,912 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
7,204 KB
testcase_07 AC 3 ms
7,120 KB
testcase_08 AC 2 ms
7,224 KB
testcase_09 AC 383 ms
71,760 KB
testcase_10 WA -
testcase_11 AC 92 ms
29,540 KB
testcase_12 AC 52 ms
21,212 KB
testcase_13 AC 32 ms
16,216 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 32 ms
14,632 KB
testcase_18 WA -
testcase_19 AC 162 ms
40,112 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 282 ms
59,080 KB
testcase_24 WA -
testcase_25 AC 153 ms
39,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List

q = 10^9+7

comb n r = iterate (scanl1 (\x y -> mod (x+y) q)) [1,1..] !! (n'-r') !! r'
 where [n',r'] = map fromIntegral [n,r]

main = getContents >>= print . kadomatsu . map read . words

kadomatsu (n:as) = mod (comb n 3) q - mod dup q
 where
  dup = sum $ map comb' $ filter (>1) $ map length $ group $ sort as
  comb' m
   | m==2 = n - m
   | otherwise = mod (comb m 2 * (n-m) + comb m 3) q
0