結果
問題 | No.1081 和の和 |
ユーザー | こまる |
提出日時 | 2020-10-24 20:08:03 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 607 bytes |
コンパイル時間 | 6,996 ms |
コンパイル使用メモリ | 166,608 KB |
実行使用メモリ | 8,412 KB |
最終ジャッジ日時 | 2023-09-28 20:44:07 |
合計ジャッジ時間 | 8,024 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,456 KB |
testcase_01 | AC | 3 ms
7,404 KB |
testcase_02 | AC | 3 ms
7,600 KB |
testcase_03 | AC | 3 ms
7,592 KB |
testcase_04 | AC | 3 ms
8,056 KB |
testcase_05 | AC | 2 ms
7,464 KB |
testcase_06 | AC | 3 ms
7,736 KB |
testcase_07 | AC | 3 ms
8,276 KB |
testcase_08 | AC | 4 ms
8,284 KB |
testcase_09 | AC | 4 ms
8,404 KB |
testcase_10 | AC | 4 ms
8,412 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
ソースコード
import qualified Data.List as L import qualified Data.Maybe as M import qualified Data.ByteString.Char8 as BSC8 main :: IO () main = do n <- readLn :: IO Integer xs <- readIntegers print . flip mod 1000000007 . snd . L.foldl1' (\acc x -> (fst x, (snd acc) + (snd x * nCr (n - 1) (fst x)))) $ zip [0..] xs readIntegers :: IO [Integer] readIntegers = map (fst . M.fromJust . BSC8.readInteger) . BSC8.words <$> BSC8.getLine factorial :: Integer -> Integer factorial n = product [1..n] nCr :: Integer -> Integer -> Integer nCr n r = (product [n-r+1 .. n]) `div` (factorial r)