結果

問題 No.754 畳み込みの和
ユーザー LeonardoneLeonardone
提出日時 2018-12-02 04:44:30
言語 Haskell
(9.8.2)
結果
AC  
実行時間 722 ms / 5,000 ms
コード長 338 bytes
コンパイル時間 2,816 ms
コンパイル使用メモリ 175,116 KB
実行使用メモリ 162,756 KB
最終ジャッジ日時 2023-09-09 23:19:34
合計ジャッジ時間 4,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 722 ms
162,640 KB
testcase_01 AC 722 ms
162,704 KB
testcase_02 AC 722 ms
162,756 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 #

-- Try yukicoder
-- author: Leonardone @ NEETSDKASU

main = interact $ show . solve . map read . words

mod109 = (`mod` (10^9 + 7))

solve (n:vs) = ans where
    (xs, ys) = splitAt (n+1) vs 
    zs = zip xs (reverse ys)
    ans = fst $ foldl f (0, 0) zs
    f (a, s) (x, y) = (mod109 $ a + (mod109 $ y * (mod109 $ s + x)), mod109 $ s + x)
0