結果

問題 No.754 畳み込みの和
コンテスト
ユーザー xsd
提出日時 2020-07-02 02:10:22
言語 OCaml
(5.5.1)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
AC  
実行時間 33 ms / 5,000 ms
+ 378µs
コード長 517 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 194 ms
コンパイル使用メモリ 22,692 KB
実行使用メモリ 9,784 KB
最終ジャッジ日時 2026-10-15 11:10:40
合計ジャッジ時間 1,601 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

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