結果

問題 No.754 畳み込みの和
ユーザー xsdxsd
提出日時 2020-07-02 02:10:22
言語 OCaml
(5.1.0)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 517 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 21,448 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-04-17 09:05:37
合計ジャッジ時間 948 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
7,168 KB
testcase_01 AC 54 ms
7,168 KB
testcase_02 AC 51 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Scanf.scanf "%d" (fun n ->
    let a = Array.init (n + 1) (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let b = Array.init (n + 1) (fun _ -> Scanf.scanf " %d" (fun b -> b)) in

    let z = 1_000_000_007 in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = (a * b) mod z in

    let rec loop i bsum acc =
        if i < 0 then acc else
            let bsum = bsum +@ b.(n - i) in
            let acc = acc +@ a.(i) *@ bsum in
            loop (i - 1) bsum acc
    in
    loop n 0 0 |> Printf.printf "%d\n"
)
0