結果
問題 | No.1081 和の和 |
ユーザー |
|
提出日時 | 2020-10-24 20:08:03 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 607 bytes |
コンパイル時間 | 7,060 ms |
コンパイル使用メモリ | 180,328 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 15:33:18 |
合計ジャッジ時間 | 6,832 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/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)