結果

問題 No.754 畳み込みの和
ユーザー ducktailducktail
提出日時 2018-12-06 14:57:46
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 381 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 165,528 KB
実行使用メモリ 104,364 KB
最終ジャッジ日時 2023-10-12 02:44:54
合計ジャッジ時間 4,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM (n + 1) readLn <*> replicateM (n + 1) readLn >>= print

solve :: [Int] -> [Int] -> Int
solve as bs = f 0 (sum as `mod` pn) (reverse as) bs
  where
    pn = 10 ^ 9 + 7
    f sm sa (a:as) (b:bs) = f ((sm + (b * sa `mod` pn)) `mod` pn) (sa - a) as bs
    f sm sa [] [] = sm
0