結果

問題 No.118 門松列(2)
ユーザー aimyaimy
提出日時 2017-04-21 16:39:02
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 462 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 159,180 KB
実行使用メモリ 43,424 KB
最終ジャッジ日時 2023-09-27 10:55:38
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 353 ms
40,936 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
7,336 KB
testcase_07 AC 2 ms
7,292 KB
testcase_08 AC 2 ms
7,296 KB
testcase_09 AC 342 ms
40,340 KB
testcase_10 WA -
testcase_11 AC 73 ms
19,024 KB
testcase_12 AC 42 ms
16,876 KB
testcase_13 AC 22 ms
13,800 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 22 ms
14,324 KB
testcase_18 WA -
testcase_19 AC 132 ms
24,268 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 232 ms
31,988 KB
testcase_24 WA -
testcase_25 AC 122 ms
24,960 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 :: [Integer] -> Integer
kadomatsu (n:as) = mod (comb n 3) q - mod dup q
 where
  dup = sum $ map comb' $ filter (>1) $ map (fromIntegral . length) $ group $ sort as
  comb' m
   | m==2 = n - m
   | otherwise = mod (comb m 2 * (n-m) + comb m 3) q
0